Repository navigation
Commit 69ea52f
authored
fix(custom-resource-handler): auto-delete-[objects|images] breaks on cloudformation rollback (#29581)
### Issue # (if applicable)
Closes #27199
### Reason for this change
Based on the way the custom resource is implemented, it is likely that
unexpected behavior happens on Cloudformation rollback, i.e. the custom
resource will prematurely delete the objects.
Consider the following scenario:
```
UPDATE target resource (replacement, creates a new resource)
UPDATE custom resource (old -> new, objects in old bucket are deleted)
(...stuff happens...)
ERROR, triggers a rollback
UPDATE custom resource (new -> old)
DELETE target resource (deletes the new resource, remembers the existing one)
```
We will have deleted objects in the bucket that has been rolled back to
in this scenario, but the content is now gone.
### Description of changes
Instead of deleting it right during update, we send back
`PhysicalResourceId` in the event handler which if the id changes, it
will let CFN to empty and delete the bucket at the end of the
deployment.
### Description of how you validated changes
New & updated tests. Also manually tested with deploying a template
```
const bucket = new s3.Bucket(this, 'Bucket', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
bucketName: <a bucket name that's not used>,
autoDeleteObjects: true,
});
// Intentionally failure since `mybucket-1` exists
const bucket2 = new s3.Bucket(this, 'Bucket2', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
bucketName: <a bucket name that's not used>,
});
bucket2.node.addDependency(bucket);
```
Once the deployment is successful, add some random content to the
bucket, then update the code so that the first bucket's bucketName is
updated to another valid name. Update the second bucket's bucketName to
be an existing bucket name, which will trigger a deployment failure
hence roll back.
After the change, the content will stay there if a deployment failure
happens. The content & bucket will be deleted if deployment is
successful.
### Checklist
- [x] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*1 parent 91246ac commit 69ea52f
197 files changed
Lines changed: 102474 additions & 73575 deletions
File tree
- packages
- @aws-cdk-testing/framework-integ/test
- aws-codepipeline-actions/test
- cloudformation/integ.stacksets.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-elastic-beanstalk-deploy.js.snapshot
- integ.pipeline-s3-deploy.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-type-v2-by-default.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-type-v2.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-with-pipeline-variables.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-dynamodb/test/integ.import-source.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-ec2/test
- integ.vpc-flow-logs-customformat.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.vpc-flow-logs-interval.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.vpc-flow-logs-kinesis.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.vpc-flow-logs.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-ecr/test/integ.repository-auto-delete-images.js.snapshot
- asset.3bbaa4a6ad9dab22284496cb250a9e77fb2f26bc181f35610877275058a4f160
- asset.4fd14d6a7a2725330bb3e0545da848df7491a1d8a0346a5ffe69c043c5681e76
- aws-ecs/test/ec2/integ.environment-file.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-elasticloadbalancingv2/test/integ.alb.log.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-lambda-event-sources/test/integ.s3.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-s3-deployment/test
- integ.bucket-deployment-cloudfront.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-deployment-deployed-bucket.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-deployment-signcontent.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-deployment.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-s3-notifications/test/sqs
- integ.bucket-notifications-unmanaged.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.4984c845346313a408899c8ff361d3b7b97953a9d4202e47694ef2a101f4b5c3.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-notifications.js.snapshot
- asset.310f432b946edeef3316f39f32b344b6bdc401a3b438433db42adadab1bf5e17.bundle
- asset.4984c845346313a408899c8ff361d3b7b97953a9d4202e47694ef2a101f4b5c3.bundle
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-s3/test
- integ.bucket-auto-delete-objects.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-import-server-access-logs.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.bucket-server-access-logs-sse-kms.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- aws-servicecatalog/test
- integ.product.js.snapshot
- integ.two-products.js.snapshot
- pipelines/test
- integ.newpipeline-with-file-system-locations.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-security.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-with-assets-single-upload.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-with-assets.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-with-variables.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline-without-prepare.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- integ.pipeline.js.snapshot
- asset.54e6f07bf3aea46d100719f3b21fe0fb45ae789ee372d42d8cdfb97e21aba96c
- asset.96ea260348625427bb7f28ab3b379f62da6f428bcd155cb13f9261aa6a404b0d
- @aws-cdk
- app-staging-synthesizer-alpha/test
- integ.synth-default-encryption.js.snapshot
- integ.synth-default-resources.js.snapshot
- custom-resource-handlers
- lib
- aws-ecr/auto-delete-images-handler
- aws-s3/auto-delete-objects-handler
- test
- aws-ecr
- aws-s3
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
0 commit comments