aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.51k stars 1.17k forks source link

Multiple lambdas using same image creates duplicate ECR+image #3750

Open grgghrn opened 2 years ago

grgghrn commented 2 years ago

I found closed issue #2576 which I believe at that point this just wasn't working at all, but it is indeed working, and this is more of a nitpicky efficiency detail I wanted to see if was possible.

I have 2 lambdas referencing the same Metadata image definitions (just different 'cmd's). It works, but it ends up creating multiple ECR's (using --resolve-image-repos), duplicating the image even though it's the same. So it's just an efficiency issue since (my upload speeds are pitiful from home!). I know it works if you manually deploy the image and reference the same ImageUri in config (if not using Metadata) so it is technically feasible.

thanks

qingchm commented 2 years ago

Thanks for mentioning this improvement idea to us, we really appreciate your feedback and will get back to you if we feel that we can address this request!

medley56 commented 2 years ago

I'd like to jump on here and request that this be addressed. One of the main benefits to dockerizing my lambdas is so that I can package all my lambda code into a single image and run multiple lambda handler commands all from the same image. There's no benefit if every lambda definition creates its own ECR and spends time rebuilding the same docker image over and over.

jtanios commented 1 year ago

Agreed. If you have 10 lambda functions all using an identical image, 10 duplicate images will be uploaded to ECR. Can SAM build & upload one image, and get all the lambdas to have the same ImageUri?

chandlersong commented 1 year ago

this feature is very useful. Hope it can be added as soon as possible

mayankkapoor commented 1 year ago

Same with me. I publish two different functions with the same image (one is a producer, another a consumer). I need to push twice. Would be great if I can use a single push via SAMCLI to publish two different functions.