question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Use 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:open
  • Created 3 years ago
  • Reactions:36
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kirintwncommented, Aug 7, 2021

Hi @heiba , I have updated my branch, added more tests & opened a PR #15932.

1reaction
MrArnoldPalmercommented, May 17, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found