A stack creates an S3 bucket that holds audit records. The stack will be deleted next week and the objects must survive. Which attribute keeps the bucket?
Show answer and explanation
Answer: A
DeletionPolicy controls what happens to a resource when its stack is deleted or when the resource is removed from the template. Retain leaves the resource and its contents in place, so the bucket becomes an ordinary standalone bucket outside CloudFormation management.
For stateful resources, Retain (or Snapshot where supported) prevents an accidental stack teardown from destroying data.
Why the other options are wrong
- B. Delete is the default behavior and removes the bucket and its objects along with the stack.
- C. UpdateReplacePolicy only governs what happens when a resource is replaced during an update; it has no effect on stack deletion.
- D. Stack policies apply to stack updates and do not block a stack delete operation.
Exam tip. DeletionPolicy handles stack deletion; UpdateReplacePolicy handles replacement.