Skip to content

Commit

Permalink
feat(bootstrap): delete noncurrent versions after 30 days (#31949)
Browse files Browse the repository at this point in the history
CDK assets in the bootstrap bucket are content-addressed and immutable so we never naturally create noncurrent versions.
However, with the introduction of the `cdk gc` command, we now have the capacity to delete unused objects in the bucket. Because the bucket is versioned by default, the delete command [actually](https://docs.aws.amazon.com/AmazonS3/latest/userguide/DeletingObjectVersions.html) just replaces the object with a new dummy version (thus the deleted object becomes noncurrent). 

Now that noncurrent objects _can_ happen, if one utilizes `cdk gc`, we are updating the bootstrap template to retain them for 30 days rather than 365 days.

Update to bootstrap version 24 to use this new lifecycle policy in conjunction with `cdk gc`. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
kaizencc authored Oct 30, 2024
1 parent 3818234 commit 579041e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ Resources:
Status: Enabled
LifecycleConfiguration:
Rules:
# Exising objects will never be overwritten but Security Hub wants this rule to exist
# Objects will only be noncurrent if they are deleted via garbage collection.
- Id: CleanupOldVersions
Status: Enabled
NoncurrentVersionExpiration:
NoncurrentDays: 365
NoncurrentDays: 30
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
StagingBucketPolicy:
Expand Down Expand Up @@ -653,7 +653,7 @@ Resources:
Type: String
Name:
Fn::Sub: '/cdk-bootstrap/${Qualifier}/version'
Value: '23'
Value: '24'
Outputs:
BucketName:
Description: The name of the S3 bucket owned by the CDK toolkit stack
Expand Down

0 comments on commit 579041e

Please sign in to comment.