A company is updating an infrastructure stack deployed via AWS CloudFormation. The template contains an Amazon DynamoDB table that needs to be modified. The planned modification requires CloudFormation to replace the DynamoDB resource. The developer wants to ensure that the database's existing data is preserved and the resource is not deleted during this replacement, as well as if the stack is deleted in the future. Which configuration should the developer apply to the DynamoDB resource in the template?
- ASpecify only DeletionPolicy with the Retain value, as this attribute automatically applies to both resource replacement updates and stack deletions.
- BApply an UpdatePolicy attribute with the AutoSnapshot property set to true, and set the DeletionPolicy to Retain.
- Specify both DeletionPolicy and UpdateReplacePolicy with the Retain value in the resource attributes.Cevap
- DEnable stack termination protection and configure a Systems Manager Parameter Store parameter to track the resource state.
Cevap
Specify both DeletionPolicy and UpdateReplacePolicy with the Retain value in the resource attributes.
To protect a resource from being deleted during both stack updates (when a change requires resource replacement) and stack deletion, you must specify both the DeletionPolicy and UpdateReplacePolicy attributes and set their values to Retain (or Snapshot if supported). Setting DeletionPolicy only protects the resource when the stack is deleted or the resource is removed from the template, but does not prevent deletion of the old resource during a replacement update. UpdateReplacePolicy specifically controls the behavior when a resource is replaced during a stack update.
Adım Adım Çözüm
Anahtar Kavram
Managing resource lifecycle and preserving data during AWS CloudFormation stack updates and deletions using DeletionPolicy and UpdateReplacePolicy.