-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
‼️ s3: toggling off auto_delete_objects for Bucket empties the bucket #16603
Comments
Hey @rittneje thanks for letting us know about this. I confirmed that the S3 is emptied when toggling Repro code import { App, Stack, RemovalPolicy } from '@aws-cdk/core';
import { Bucket, BlockPublicAccess } from '@aws-cdk/aws-s3'
const app = new App();
const stack = new Stack(app, 'issue-16603');
const bucket = new Bucket(stack, 'Issue16603TestBucket', {
bucketName: 'issue-16603-test-bucket',
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: RemovalPolicy.DESTROY, // change to `.RETAIN` on 2nd deploy
autoDeleteObjects: true // change to `false` on 2nd deploy
}); Labeling this as p1 which means it has been prioritized as important, although please keep in mind that we do have a large number of issues at the moment. It may be some time before we are able to solve this particular issue. We use +1s to help us prioritize our work, and as always we are happy to take contributions if anyone is interested to pick this up and submit a PR. |
Upgrading to p0 based on the potential to lose data without warning. |
This was caused by the Custom Resource--which had previously been deployed when `autoDeleteObjects: true`--being removed when `autoDeleteObjects` is flipped off again. The custom resource would indiscriminately empty the bucket as it was being deleted. Fix by having the custom resource inspect the ongoing CloudFormation deployment: if the bucket would not be deleted as part of the ongoing deployment, also do not empty it. Fixes #16603.
…16756) This was caused by the Custom Resource--which had previously been deployed when `autoDeleteObjects: true`--being removed when `autoDeleteObjects` is flipped off again. The custom resource would indiscriminately empty the bucket as it was being deleted. Fix by tagging the bucket to confirm that it needs to be emptied. If any deployment removes the CR but keeps the bucket, the ordering of CloudFormation updates will make sure that the untagging happens before the CR gets activated, thereby saving the bucket contents. Fixes #16603. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
Fix released in v1.126.0 If you have deployed a bucket with |
@ryparker To be clear, I think you have to actually deploy the stack in question with 1.126.0+ at least once before switching the value to |
|
Thanks for the mailing! |
@ryparker what about CDK v2? Do you know what is the min version I can safely redeploy with? |
…16756) This was caused by the Custom Resource--which had previously been deployed when `autoDeleteObjects: true`--being removed when `autoDeleteObjects` is flipped off again. The custom resource would indiscriminately empty the bucket as it was being deleted. Fix by tagging the bucket to confirm that it needs to be emptied. If any deployment removes the CR but keeps the bucket, the ordering of CloudFormation updates will make sure that the untagging happens before the CR gets activated, thereby saving the bucket contents. Fixes #16603. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Can anyone say if we need to update all package references, or if it's enough to just have the latest CDK cli? |
@benm5678 You need to update all the references. |
…ws#16756) This was caused by the Custom Resource--which had previously been deployed when `autoDeleteObjects: true`--being removed when `autoDeleteObjects` is flipped off again. The custom resource would indiscriminately empty the bucket as it was being deleted. Fix by tagging the bucket to confirm that it needs to be emptied. If any deployment removes the CR but keeps the bucket, the ordering of CloudFormation updates will make sure that the untagging happens before the CR gets activated, thereby saving the bucket contents. Fixes aws#16603. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
If a stack is deployed with an S3 bucket with
auto_delete_objects=True
, and then re-deployed withauto_delete_objects=False
, all the objects in the bucket will be deleted.Reproduction Steps
auto_delete_objects=True
.auto_delete_objects=False
.What did you expect to happen?
The bucket should not have been emptied.
What actually happened?
Since the custom resource was deleted, the bucket was emptied.
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: