Deletion policies
When we create our stack, we need to make sure that mission-critical resources are protected from accidental deletion.
In some cases, this is enabled by EnableTerminationProtection
for services such as EC2 and RDS. S3 buckets, when filled with objects, will fail to delete because they have to be emptied first.
Deletion policies allow you to mitigate this risk within CloudFormation. In addition, deletion policies give you a few more features in addition to basic termination protection.
For example, say that you have created a testing stack that you don't need once the testing phase is finished, but you need the dump of the database (which is actually a snapshot of the RDS instance). Sometimes, you don't want to recreate the same data structure, or the database already has important data that you want to move to the production environment.
Let's see whether deletion policies can help us:
Resources: Â Â VeryImportantDb: Â Â ...