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

Feature Request: Set ECR Lifecycle when deploying a lambda with a docker image #6917

Open
concavegit opened this issue Apr 7, 2024 · 4 comments
Labels
type/feature Feature request

Comments

@concavegit
Copy link

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?

@concavegit concavegit added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Apr 7, 2024
@gracelu0
Copy link

gracelu0 commented Apr 8, 2024

Hi @concavegit , this looks like a SAM CLI related question so I'll transfer this issue to the SAM CLI repo.

@gracelu0 gracelu0 transferred this issue from aws/serverless-application-model Apr 8, 2024
@lucashuy
Copy link
Contributor

lucashuy commented Apr 8, 2024

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.

@lucashuy lucashuy added blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days type/feature Feature request and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Apr 8, 2024
@concavegit
Copy link
Author

concavegit commented Apr 8, 2024

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.

@lucashuy
Copy link
Contributor

lucashuy commented Apr 8, 2024

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.

@mndeveci mndeveci removed the blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days label May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature Feature request
Projects
None yet
Development

No branches or pull requests

4 participants