How can this be achieved in a reliable and efficient way?
Write a script to continue backing up the RDS instance every five minutes
Create an AWS Lambda function to take a snapshot of the RDS instance, and manually execute the function before deleting the stack
Use the Snapshot Deletion Policy in the CloudFormation template definition of the RDS instance
Create a new CloudFormation template to perform backups of the RDS instance, and run this template before deleting the stack
Explanations:
Writing a script to back up the RDS instance every five minutes is not an efficient or reliable way to ensure the data is retained after the stack is deleted. It introduces complexity and management overhead.
Creating an AWS Lambda function to manually snapshot the RDS instance before deleting the stack is not ideal, as it requires manual intervention, making it error-prone and less automated.
Using the Snapshot Deletion Policy in the CloudFormation template ensures that RDS snapshots are retained even after the stack is deleted, making it a reliable and automated solution for preserving data.
Creating a new CloudFormation template to perform backups before deleting the stack introduces unnecessary complexity. This approach does not take advantage of CloudFormation’s native snapshot management features.