DVA-C02 · Question #546
A team deploys an AWS CloudFormation template to update a stack that already included an Amazon DynamoDB table. However, before the deployment of the update, the team changed the name of the DynamoDB
The correct answer is A. CloudFormation will create a new table and will delete the existing table.. When a DynamoDB table is renamed in a CloudFormation template, CloudFormation treats it as a resource replacement: it creates a new table with the new name and deletes the original, because the default DeletionPolicy is Delete.
Question
A team deploys an AWS CloudFormation template to update a stack that already included an Amazon DynamoDB table. However, before the deployment of the update, the team changed the name of the DynamoDB table on the template by mistake. The DeletionPolicy attribute for all resources has the default value. What will be the result of this mistake?
Options
- ACloudFormation will create a new table and will delete the existing table.
- BCloudFormation will create a new table and will keep the existing table.
- CCloudFormation will overwrite the existing table and will rename the existing table.
- DCloudFormation will keep the existing table and will not create a new table.
How the community answered
(23 responses)- A65% (15)
- B4% (1)
- C22% (5)
- D9% (2)
Why each option
When a DynamoDB table is renamed in a CloudFormation template, CloudFormation treats it as a resource replacement: it creates a new table with the new name and deletes the original, because the default DeletionPolicy is Delete.
CloudFormation identifies resources by their logical ID and physical name properties. Changing the table name causes CloudFormation to determine that the existing resource must be replaced. With the default DeletionPolicy of Delete, CloudFormation first creates the new table with the updated name and then deletes the old table, resulting in data loss.
Retaining the existing table requires explicitly setting DeletionPolicy to Retain; the default value is Delete, so the old table will be removed.
CloudFormation cannot rename a DynamoDB table in place; a name change triggers a full resource replacement, not an in-place update.
CloudFormation will proceed to create the new table under the updated name; it does not silently skip resource creation when a name changes.
Concept tested: CloudFormation DeletionPolicy default behavior on resource replacement
Source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
Community Discussion
No community discussion yet for this question.