You've created a Cloudformation template as per your team's request which is required for testing an application.
The requirement is that when there is a request for stack deletion, the database should still be preserved for future reference.How can you achieve this using Cloudformation?
Click on the arrows to vote for the correct answer
A. B. C. D.Answer - B.
With the DeletionPolicy attribute you can preserve or (in some cases) backup a resource when its stack is deleted.
You specify a DeletionPolicy attribute for each resource that you want to control.
If a resource has no DeletionPolicy attribute, AWS CloudFormation deletes the resource by default.
Note that this capability also applies to update operations that lead to resources being removed.
For more information on Cloudformation Deletion policy, please visit the below URL:
http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.htmlThe correct answer for this question is B: In the AWS CloudFormation template, set the DeletionPolicy of the AWS::RDS::DBInstance's DeletionPolicy property to “Retain.”
When you delete a CloudFormation stack, all resources created as part of the stack are deleted by default. However, you can specify a DeletionPolicy for each resource in your CloudFormation template to determine what happens to the resource when the stack is deleted.
The AWS::RDS::DBInstance resource type creates an Amazon RDS database instance, which is a fully managed relational database service. By default, when a CloudFormation stack that includes an RDS DB instance is deleted, the database is also deleted. This behavior can be modified using the DeletionPolicy property.
To preserve the database when the CloudFormation stack is deleted, you can set the DeletionPolicy of the AWS::RDS::DBInstance resource to “Retain”. This will prevent CloudFormation from deleting the database when the stack is deleted, allowing you to preserve the data for future reference.
Option A, ensuring that the RDS is created with Read Replica's is not a suitable solution to achieve the requirement mentioned in the question. Creating a Read Replica does not prevent the original RDS instance from being deleted when the CloudFormation stack is deleted.
Option C, setting the WaitPolicy of the AWS::RDS::DBInstance resource to “Retain” is not a valid option, as there is no such property called WaitPolicy for the AWS::RDS::DBInstance resource type.
Option D, setting the AWS::RDS::DBInstance's DBInstanceClass property to be read-only is also not a suitable solution to achieve the requirement mentioned in the question. The DBInstanceClass property is used to specify the compute and memory capacity of the RDS instance, and setting it to read-only would not prevent the database from being deleted when the CloudFormation stack is deleted.