A CloudFormation stack contains an RDS DB instance (AWS::RDS::DBInstance) resource.
You use a Jenkins job to perform the stack update when the CloudFormation template has a change.
When a replacement of the DB instance resource is required during a stack update, you want to ensure that the old DB instance is retained after the new DB instance is created.
Which of the following resource attributes would you use for the DB resource?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer: B.
Option A is incorrect because DeletionPolicy is used for resources deleted when a stack is deleted, or when the resource definition itself is deleted from the template as part of a stack update.
In this question, the stack is being updated instead of deleted.
Option B is CORRECT because UpdateReplacePolicy applies to resources replaced during stack updates.
In this question, you should configure the DB instance with “UpdateReplacePolicy: Retain”.
Option C is incorrect because the UpdatePolicy attribute specifies how AWS CloudFormation handles updates to the AWS::AutoScaling::AutoScalingGroup, AWS::ElastiCache::ReplicationGroup, AWS::Elasticsearch::Domain, or AWS::Lambda::Alias resources.
It does not work with DB instance resources.
Option D is incorrect because CreationPolicy does not specify whether or not a DB instance would be retained during a stack update.
Reference:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-updatereplacepolicy.htmlIn this scenario, you are updating a CloudFormation stack that contains an RDS DB instance resource. When the CloudFormation template changes, a replacement of the DB instance resource is required during the stack update. You want to ensure that the old DB instance is retained after the new DB instance is created.
To achieve this, you can use the UpdatePolicy attribute for the DB resource. The UpdatePolicy attribute allows you to specify how CloudFormation handles updates to the resource. Specifically, you can use the RetainResources property to specify which resources should be retained when the resource is replaced during an update.
The RetainResources property takes a list of resource logical IDs. In this case, you would specify the logical ID of the old DB instance resource to ensure that it is retained after the new DB instance is created.
The other resource attributes listed in the answer choices are as follows:
A. DeletionPolicy: This attribute specifies what happens to the resource when the stack is deleted. It does not affect how the resource is updated.
B. UpdateReplacePolicy: This attribute specifies what happens to the resource when it is replaced during an update. It does not allow you to specify which resources should be retained.
D. CreationPolicy: This attribute allows you to specify conditions that must be met before the resource is created. It does not affect how the resource is updated.
Therefore, the correct answer to this question is C. UpdatePolicy.