(ecr): add option to auto delete images upon ECR repository removal
See original GitHub issueUse Case
ECR repositories currently do not get delete if they contain images even the removalPolicy
is set to DESTROY
.
It was reported in #2765, and was thought to be a responsibility of CloudFormation team https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/515.
Proposed Solution
I do think we should add a option to force delete the images using custom resource provider, which is just like #12090 that uses a custom resource provider to delete objects in s3.
The code might looks like this:
const bucket = new ecr.Repository(this, 'Repo', {
repositoryName: 'delete-even-if-contains-images',
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteImages: true,
});
The props autoDeleteImages
can only to be true if removalPolicy
is set to DESTROY
.
Other
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:36
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Clean up Your Container Images with Amazon ECR Lifecycle ...
Starting today, customers can keep their container image repositories tidy by automatically removing old or unused images using lifecycle ...
Read more >Automation Deletion Untagged Container Image in Amazon ...
In this article, I will discuss how to create automation for deletion untagged container image in ECR using ECR Lifecycle Policy. Lifecycle policy...
Read more >Delete ECR images using CloudFormation Custom Resources
In this case, we will use CloudFormation custom resources to automatically remove the images from the ECR repository when deleting the ...
Read more >ECR Lifecycle policy: Simplest way to get rid of older images
AWS Elastic container registry is the best choice to store our ... With ECR Lifecycle Policy, we can expire/delete images based on age...
Read more >How to Delete AWS ECR Untagged and Older Images?
Step 3: ECR allows you to delete images on two conditions, one being if your images get specified days old or if they...
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @heiba , I have updated my branch, added more tests & opened a PR #15932.
hey @kirintwn, would you be interested in publishing this as a separate module? There definitely is a need and it would be a good way to get some users testing it before merging into the CDK. It may be possible to extend the existing ecr.Repository class and intercept this prop and then create the custom resource.