Skip to content

Commit c377c34

Browse files
authored
docs(s3): update documentation for more context around autoDeleteObjects (#30096)
### Issue # (if applicable) [29873](#29873) ### Description of changes This the documentation update to notify users that upon setting the `autoDeleteObjects` to `true` we would also add a new policy `s3:PutBucketPolicy` to handle race conditions. ### 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 9c3f3f5 commit c377c34

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

packages/aws-cdk-lib/aws-s3/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ as it does not contain any objects.
622622
To override this and force all objects to get deleted during bucket deletion,
623623
enable the`autoDeleteObjects` option.
624624

625+
When `autoDeleteObjects` is enabled, `s3:PutBucketPolicy` is added to the bucket policy. This is done to allow the custom resource this feature is built on to add a deny policy for `s3:PutObject` to the bucket policy when a delete stack event occurs. Adding this deny policy prevents new objects from being written to the bucket. Doing this prevents race conditions with external bucket writers during the deletion process.
626+
625627
```ts
626628
const bucket = new s3.Bucket(this, 'MyTempFileBucket', {
627629
removalPolicy: cdk.RemovalPolicy.DESTROY,

packages/aws-cdk-lib/aws-s3/lib/bucket.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,11 @@ export interface BucketProps {
14711471
* all objects in the bucket being deleted. Be sure to update your bucket resources
14721472
* by deploying with CDK version `1.126.0` or later **before** switching this value to `false`.
14731473
*
1474+
* Setting `autoDeleteObjects` to true on a bucket will add `s3:PutBucketPolicy` to the
1475+
* bucket policy. This is because during bucket deletion, the custom resource provider
1476+
* needs to update the bucket policy by adding a deny policy for `s3:PutObject` to
1477+
* prevent race conditions with external bucket writers.
1478+
*
14741479
* @default false
14751480
*/
14761481
readonly autoDeleteObjects?: boolean;

0 commit comments

Comments
 (0)