From 579041e5d41e780ce1f6fb9f778c353868fb6938 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:28:48 -0400 Subject: [PATCH] feat(bootstrap): delete noncurrent versions after 30 days (#31949) 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* --- packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml b/packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml index ad71c39535426..164f72d626c53 100644 --- a/packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml +++ b/packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml @@ -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: @@ -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