I'm using CloudFormation to construct an AWS::DynamoDB::Table
resource, and I have my DeletionPolicy
set to Retain
. Suppose I make a change to the AttributeDefinitions
properties of this logical resource, such as renaming a hash key, and then perform a CloudFormation update_stack
; such a change requires a 'replacement' of the resource. So far so good; I expect that the existing DynamoDB table is 'deleted' and a new one created in its place with the changed key definition.
However, I'm surprised that the original table is not 'left behind' as a result of the DeletionPolicy
. Certainly, it would be possible to block the update entirely via a stack policy, but I was hoping that the DeletionPolicy would result in the now-defunct table being ejected from the CloudFormation stack and a new one arising in its place, but nonetheless not actually deleted.
Is this expected behaviour?
DeletionPolicy options. CloudFormation deletes the resource and all its content if applicable during stack deletion. You can add this deletion policy to any resource type. By default, if you don't specify a DeletionPolicy , CloudFormation deletes your resources.
Using the NoEcho attribute does not mask any information stored in the following: The Metadata template section. CloudFormation does not transform, modify, or redact any information you include in the Metadata section.
DynamoDB achieves a high degree of data availability and durability by replicating your data across three different facilities within a given region. However, DynamoDB does not provide an SLA for the data durability. This means that you should backup your database tables.
Yes, it is an expected behavior.
The DeletionPolicy
is only applied when you actually delete the whole CloudFormation stack.
Source: DeletionPolicy @ docs.aws.amazon.com
If you want to keep your former DynamoDB tables during an update, you will need to back it up manually beforehand. You may use AWS Data Pipeline to backup your DynamoDB tables on Amazon S3.
Use AWS attribute "UpdateReplacePolicy: Retain".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With