Skip to content
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

feat(ecr): add option to auto delete images upon ECR repository removal #24572

Merged
merged 21 commits into from
Mar 21, 2023
Merged

feat(ecr): add option to auto delete images upon ECR repository removal #24572

merged 21 commits into from
Mar 21, 2023

Conversation

randyridgley
Copy link
Contributor

@randyridgley randyridgley commented Mar 10, 2023

This request fixes the ECR Repository resource to allow setting a flag on the resource to auto delete the images in the repository. This is similar to the way S3 handles the autoDeleteObjects attribute. This code base starts from a stalled PR #15932. This also takes into account the functionality added into S3 to create tag to not delete images if the flag is flipped from true to false.

Closes #12618
References closed and not merged PR #15932


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added the p2 label Mar 10, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team March 10, 2023 18:16
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Mar 10, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@randyridgley randyridgley changed the title (ecr): add option to auto delete images upon ECR repository removal feat(ecr): add option to auto delete images upon ECR repository removal Mar 10, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review March 10, 2023 20:07

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

Just some small feedback, otherwise this looks pretty good.

packages/@aws-cdk/aws-ecr/lib/repository.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-ecr/lib/repository.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed MrArnoldPalmer’s stale review March 21, 2023 19:12

Pull request has been modified.

Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

Just a small convention change, otherwise I think we are good.

packages/@aws-cdk/aws-ecr/lib/repository.ts Outdated Show resolved Hide resolved
Co-authored-by: Mitchell Valine <mitchellvaline@gmail.com>
@mergify mergify bot dismissed MrArnoldPalmer’s stale review March 21, 2023 21:56

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Mar 21, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: e6ed559
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 7de5b00 into aws:main Mar 21, 2023
@mergify
Copy link
Contributor

mergify bot commented Mar 21, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 28, 2023
…al (aws#24572)

This request fixes the ECR Repository resource to allow setting a flag on the resource to auto delete the images in the repository. This is similar to the way S3 handles the autoDeleteObjects attribute. This code base starts from a stalled PR [aws#15932](aws#15932). This also takes into account the functionality added into S3 to create tag to not delete images if the flag is flipped from true to false. 

Closes [aws#12618](aws#12618)
References closed and not merged PR  [aws#15932](aws#15932)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mergify bot pushed a commit to CloudSnorkel/cdk-github-runners that referenced this pull request Nov 30, 2023
…r us (#476)

AWS Image Builder [recently introduced lifecycle rules](https://aws.amazon.com/about-aws/whats-new/2023/11/ec2-image-builder-lifecycle-management-deletion/) that can help us remove old images from EC2/ECR, and their descriptors on AWS Image Builder side.

CDK [added automatic deletion of images in repositories](aws/aws-cdk#24572) so they can be deleted in CloudFormation easily. We had a custom resource to delete images, but now we can just use `autoDeleteImages`.

We still have to clean-up AWS Image Builder image descriptors and AMIs with a custom resource. We do this so removing our construct won't leave anything behind.

Resolves #471

BREAKING CHANGE: CDK 2.110.0 and above is required
mergify bot pushed a commit that referenced this pull request Dec 19, 2023
… construct (#28233)

Added `emptyOnDelete` prop to the ecr `Repository` construct. `emptyOndelete` is supported by CloudFormation 
See here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-emptyondelete


I've also deprecated the `autoDeleteImages` prop that deployed a custom resource. According to #24572 this was added before CloudFormation added the `EmptyOnDelete` property here aws-cloudformation/cloudformation-coverage-roadmap#515

Closes #28196 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(ecr): add option to auto delete images upon ECR repository removal
3 participants