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
Feature Request: Set ECR Lifecycle when deploying a lambda with a docker image #6917
Comments
Hi @concavegit , this looks like a SAM CLI related question so I'll transfer this issue to the SAM CLI repo. |
Thanks for raising this to us. How are your current images being uploaded to ECR? Are they being stored in an ECR repository that you control, or is this with the ECR repository that SAM CLI creates for you? If a custom ECR is being used, then its possible to define lifecycle (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ecr-repository.html#cfn-ecr-repository-lifecyclepolicy) to manage older images. This solution may not consider images that are being used by functions, so please be aware. Doing this automatically with SAM CLI might be out of scope for our tooling (namely requiring additional permissions, and having some kind of persistent background task), and might be better managed with other solutions. Tagging as close-if-inactive as it seems unlikely for us to accept this. |
My images are being uploaded to ECR to the repository that SAM CLI creates for me. Blocked/close-if-inactive works for me, I just wanted to check if there is already a feature request I could track or if there was a solution I overlooked. I'll manually clean up my containers for now. I don't think this will require significant additional permissions or any background task sinces ECR already supports a lifecycle policy. |
Thanks for getting back. I've checked in with the team to see if there are other solutions that you or I have missed in this issue. It might be possible to write some custom logic that lives in a Lambda function to check and delete images based on a couple of conditions (eg. whether or not they are in use, age of image, number of images), but doing this automatically as part of SAM CLI might be out of scope. I'll leave this issue open for now in case I have other solutions, or other readers have ideas. |
I am followingthis guide to create a SAM template that deploys a lambda based on a Dockerfile. However, each
sam deploy
creates a new image, which causes me to pay for multiple old registries until I manually delete them. Is there a way to make a policy to retain only the past five containers, or even better the last 30 days of containers?The text was updated successfully, but these errors were encountered: