AWS Certified DevOps Engineer - Professional free question 3 / 10 · Domain 2: Configuration Management and IaC
A template defines an RDS DB instance with DeletionPolicy set to Retain. A developer changes the Engine property of the instance, and the stack update replaces it. The old DB instance is gone after the update. What should the team add so that the old instance is kept in future replacements?
- A CreationPolicy on the DB instance, so that CloudFormation waits before it deletes the old instance
- A DeletionPolicy of Snapshot in place of Retain on the DB instance, for replacements during an update
- An update through a change set, as the attribute is applied for updates made through change sets and not for direct updates
- UpdateReplacePolicy with the value Retain, or Snapshot, on the DB instance
Show the answer and explanation
Answer: D
Why this is correct
When a property change requires replacement, CloudFormation creates the new resource first, moves the references and then deletes the old one by default. UpdateReplacePolicy lets you retain the old resource or, for resources that support snapshots, take a snapshot of it. DeletionPolicy covers stack deletion and removal of a resource from the template, so it does not protect an instance that is replaced during an update. The DeletionPolicy page says that this capability does not apply to resources whose physical instance is replaced during stack update operations.
Why the other options are wrong
"A DeletionPolicy of Snapshot in place of Retain on the DB instance, for replacements during an update" … DeletionPolicy does not apply to resources whose physical instance is replaced during stack update operations. UpdateReplacePolicy is the attribute for replacements.
"A CreationPolicy on the DB instance, so that CloudFormation waits before it deletes the old instance" … The creation policy page says that a creation policy is invoked when CloudFormation creates the resource. It does not decide what happens to the old resource after a replacement.
"An update through a change set, as the attribute is applied for updates made through change sets and not for direct updates" … UpdateReplacePolicy applies to stack updates that you perform directly, in addition to updates through change sets, and it must be set on the resource.
Key points
Pair DeletionPolicy with UpdateReplacePolicy for stateful resources: one covers deletion, the other covers replacement.