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.htmlThe correct answer is C. UpdatePolicy.
Explanation:
During a CloudFormation stack update, AWS can replace certain resources to apply the changes in the stack template. When a resource is replaced, the old resource is deleted and a new resource is created.
In this scenario, the requirement is to retain the old DB instance after the new DB instance is created. To achieve this, you need to specify an update policy for the RDS DB instance resource.
The available options for the update policy are:
DeletionPolicy: This attribute specifies what happens to the resource when it is deleted from the stack. It does not apply to resource replacement during a stack update.
UpdateReplacePolicy: This attribute specifies whether to replace the resource during a stack update or not. If this attribute is set to "Retain", then the old resource is retained, and a new resource is created. However, this attribute applies to all updates, not just replacements.
CreationPolicy: This attribute specifies a set of conditions that must be met before the resource is considered created. It does not apply to resource replacement during a stack update.
UpdatePolicy: This attribute applies only during updates and is used to specify how to handle a resource replacement. You can use this attribute to specify how to retain the old resource after a new resource is created. The most commonly used attribute within UpdatePolicy is "AutoScalingRollingUpdate", which provides a rolling update mechanism that replaces resources in small batches while retaining the old resources until the new ones are ready.
Therefore, the correct answer is C. UpdatePolicy. You can use the UpdatePolicy attribute to specify how to retain the old DB instance after a new DB instance is created during a stack update.