ECR lifecycle policy || images not in use

1

I want to create an ECR lifecycle policy rule in AWS that satisfies following conditions.

Expire images older than 60days In some cases, the image in use is older than 60 days so should not be deleted, so should exclude images in use I have tried different rules but i don't think the "in use" status exists or I am missing something, can anyone please help me with this.

1 Answer
0

There is no such thing as an image in use. ECS will download the image from the ECR when the container is launched. There is no way to tell what images are in use im afraid.

The only way you "could" do this is with some custom automation using somthing like a lambda or step function. To list all your task definitions which are in use, grab the container image SHA/tag thats in use. Then list all images in the ECR and delete the ones older than 60 days but exlude the ones in the list of in use.

profile picture
EXPERT
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions