Skip to content

Commit

Permalink
s3.Bucket: auto-delete-objects integ test
Browse files Browse the repository at this point in the history
  • Loading branch information
samson-keung committed May 25, 2024
1 parent d296fb3 commit 61a02d0
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"LogGroupF5B46931": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": "AutoDeleteObjectsLambdaLogs",
"RetentionInDays": 3
},
"UpdateReplacePolicy": "Retain",
"DeletionPolicy": "Retain"
},
"RemovedBucket4FCCEBAD": {
"Type": "AWS::S3::Bucket",
"Properties": {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { App, CustomResource, CustomResourceProvider, RemovalPolicy, Stack, Stac
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as logs from 'aws-cdk-lib/aws-logs';
import { RetentionDays } from 'aws-cdk-lib/aws-logs';
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources';
import { STANDARD_CUSTOM_RESOURCE_PROVIDER_RUNTIME } from '../../config';

Expand Down Expand Up @@ -38,6 +40,10 @@ class TestStack extends Stack {
const bucketThatWillBeRemoved = new s3.Bucket(this, 'RemovedBucket', {
removalPolicy: RemovalPolicy.DESTROY,
autoDeleteObjects: true,
autoDeleteObjectsLogGroup: new logs.LogGroup(this, 'LogGroup', {
logGroupName: 'AutoDeleteObjectsLambdaLogs',
retention: RetentionDays.THREE_DAYS,
}),
});

// Remove this bucket immediately
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-s3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ Pass a custom log group via the `autoDeleteObjectsLogGroup` option, which will b
const bucket = new s3.Bucket(this, 'MyTempFileBucket', {
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
autoDeleteObjectsLogGroup: new LogGroup(stack, 'LogGroup', {
autoDeleteObjectsLogGroup: new logs.LogGroup(stack, 'LogGroup', {
logGroupName: 'MyLogGroup',
retention: RetentionDays.TWO_YEARS
})
Expand Down

0 comments on commit 61a02d0

Please sign in to comment.