Manually reverting to a RDS snapshot means creating a new database and updating the app references to that. For pulumi this means updating the stack with the new snapshot identifier.
- Go to AWS Console and select RDS
- Select the database instance
- Select the tab "Maintenance & backups" and navigate to the "Snapshots"
- Select the snapshot you want to revert to
- Copy the snapshot ARN (identifier), e.g.
arn:aws:rds:eu-north-1:1234567890:snapshot:initial-backup-test - With a code editor: update the pulumi stack with the new snapshot identifier:
// Update the RDS instance to use the manually created snapshot
var instanceName = "keep-the-same-name-as-before";
var rdsPostGreInstance = new Instance(instanceName, new InstanceArgs()
{
// ... other configuration options
SnapshotIdentifier = snapshotArn, // eg. "arn:aws:rds:eu-north-1:1234567890:snapshot:initial-backup-test",
});
- Run
pulumi upto update the stack (depending on the config the database might be destroyed and recreated, or just updated with the snapshot, check the output of thepulumi upcommand to see what will happen before confirming the update) - Ensure that the stack is updated with the newly created database and that the data reflects the snapshot
- Remove the
SnapshotIdentifierfrom the pulumi code and runpulumi upagain to remove the reference to the snapshot
var instanceName = "keep-the-same-name-as-before";
var rdsPostGreInstance = new Instance(instanceName, new InstanceArgs()
{
// ... other configuration options
});- Ensure the database works as expected
- Resolve the pulumi stack output for the database migrator lambda function ARN:
AdminFunctionArn - Invoke the function:
- with AWS CLI:
aws lambda invoke --payload '{"Action": "Migrate"}' --cli-binary-format raw-in-base64-out --function-name <AdminFunctionArn> output.json - or by using the AWS Console:
- Go to AWS Console and select Lambda
- Select the function with name like
users-api-AdminFunction-<stage>-<random-hash> - Select the tab "Test"
- Add a new test event with the following content:
{"Action": "Migrate"} - Click "Test" button and wait for the execution to finish