Describe the bug
This one was a surprise and only came about because of a mistake. This issue has been replicated with CDK 2.1138.0 (build a4c0282).
An existing CFN stack (created by CDK) with a resource with a DeletionPolicy can be updated outside of CDK in a way that breaks all future CDK runs against that stack, while being perfectly acceptable to CloudFormation.
Regression Issue
Last Known Working CDK Library Version
No response
Expected Behavior
CDK should not break on existing templates that CloudFormation is quite happy with
Current Behavior
A manual update to a stack can cause CDK to fail in unexpected ways; diagnosing the problem via the console or AWS CLI does NOT reveal the problem.
Reproduction Steps
- Start with an existing CDK app created without modification using the CDK "getting started" example (
mkdir hello-world && cd hello-world && cdk init sample-app --language=typescript) and deployed
- Copy the JSON template (either from the CloudFormation console, or from
aws cloudformation get-template ...) and, in the resource definition for the AWS::SQS::Queue, make the following change:
FROM
"CdkShouldFailQueueF196B131": {
"Type": "AWS::SQS::Queue",
"Properties": {
"VisibilityTimeout": 300
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"Metadata": {
"aws:cdk:path": "CdkShouldFailStack/CdkShouldFailQueue/Resource"
}
},
TO
"CdkShouldFailQueueF196B131": {
"Type": "AWS::SQS::Queue",
"Properties": {
"VisibilityTimeout": 300
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete",
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "RetainExceptOnCreate",
"Metadata": {
"aws:cdk:path": "CdkShouldFailStack/CdkShouldFailQueue/Resource"
}
},
A second UpdateReplacePolicy and DeletionPolicy key has been added.
3. Update the stack in place (either via changeset or directly), using the console or command line but NOT using CDK
4. Now do cdk diff and see the failure Map keys must be unique; "UpdateReplacePolicy" is repeated
Possible Solution
No response
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.266.0
AWS CDK CLI version
2.1138.0 (build a4c0282)
Node.js Version
Node.js v22.22.2
OS
Linux (Fedora 43)
Language
TypeScript
Language Version
No response
Other information
No response
Describe the bug
This one was a surprise and only came about because of a mistake. This issue has been replicated with CDK 2.1138.0 (build a4c0282).
An existing CFN stack (created by CDK) with a resource with a
DeletionPolicycan be updated outside of CDK in a way that breaks all future CDK runs against that stack, while being perfectly acceptable to CloudFormation.Regression Issue
Last Known Working CDK Library Version
No response
Expected Behavior
CDK should not break on existing templates that CloudFormation is quite happy with
Current Behavior
A manual update to a stack can cause CDK to fail in unexpected ways; diagnosing the problem via the console or AWS CLI does NOT reveal the problem.
Reproduction Steps
mkdir hello-world && cd hello-world && cdk init sample-app --language=typescript) and deployedaws cloudformation get-template ...) and, in the resource definition for theAWS::SQS::Queue, make the following change:FROM
TO
A second
UpdateReplacePolicyandDeletionPolicykey has been added.3. Update the stack in place (either via changeset or directly), using the console or command line but NOT using CDK
4. Now do
cdk diffand see the failureMap keys must be unique; "UpdateReplacePolicy" is repeatedPossible Solution
No response
Additional Information/Context
No response
AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.266.0
AWS CDK CLI version
2.1138.0 (build a4c0282)
Node.js Version
Node.js v22.22.2
OS
Linux (Fedora 43)
Language
TypeScript
Language Version
No response
Other information
No response