Skip to content

chore: Easier way to delete snapshots for old AMIs #728

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kichik
Copy link
Member

@kichik kichik commented Jun 5, 2025

No description provided.

@kichik kichik requested a review from Copilot June 5, 2025 19:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the deletion of snapshots for outdated AMIs by updating asset references and leveraging the AWS SDK's built-in capability to delete associated snapshots.

  • Consolidated asset hash updates in JSON templates.
  • Removed the manual snapshot deletion loop from the Lambda function.
  • Added the "DeleteAssociatedSnapshots" flag to automate snapshot deletion.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/default.integ.snapshot/github-runners-test.template.json Updated S3Key to reference the new asset hash
test/default.integ.snapshot/github-runners-test.assets.json Updated asset key identifiers and corresponding objectKey values
src/image-builders/aws-image-builder/delete-resources.lambda.ts Simplified resource deletion by removing the manual snapshot deletion loop and using DeleteAssociatedSnapshots
Comments suppressed due to low confidence (1)

src/image-builders/aws-image-builder/delete-resources.lambda.ts:72

  • Verify that the 'DeleteAssociatedSnapshots' flag is supported by the current AWS SDK version and behaves as expected to automatically remove associated snapshots.
        DeleteAssociatedSnapshots: true,

@@ -9556,7 +9556,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "bfba719fe2a2764d7716a472198f4f8cbe46f6ea4616cd6ba0ebf26e75954814.zip"
"S3Key": "b97c8701d090be54cf447e094fd55ece7c99b860476949ee5db7ceca6eeb2f6a.zip"
Copy link
Preview

Copilot AI Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider centralizing asset hash values (and thus S3Key values) to reduce duplication and ease future updates.

Suggested change
"S3Key": "b97c8701d090be54cf447e094fd55ece7c99b860476949ee5db7ceca6eeb2f6a.zip"
"S3Key": {
"Ref": "LambdaS3Key"
}

Copilot uses AI. Check for mistakes.

@kichik
Copy link
Member Author

kichik commented Jun 7, 2025

Lambda currently comes bundled with version 3.774.0 of AWS SDK v3, but we need 3.819.0 and above for this.

@kichik
Copy link
Member Author

kichik commented Jun 24, 2025

Now it's at 3.806.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant