I have a Lambda deployed on AWS. My Lambda is deployed uses a container to run my code. Whenever after we deploy a new image, we have to manually copy paste the URL in Lambda's configuration. Even if in ECR latest image has the URI which is already configured in Lambda, Lambda used the image from when configuration was last manually done. I was wondering if there is a way to automatically have lambda use the latest image that is deployed in ECR ?
Things I have tried:
Note: Image is being pushed to ECR by Bitbucket.
This is expected as the Lambda isn't aware a new image was pushed.
For a function defined as a container image, Lambda resolves the image tag to an image digest. In Amazon ECR, if you update the image tag to a new image, Lambda does not automatically update the function.
https://docs.aws.amazon.com/cli/latest/reference/lambda/update-function-code.html#update-function-code
After pushing the image:
docker tag my-image:latest 123456789.dkr.ecr.eu-west-1.amazonaws.com/my-image:latest
docker push 123456789.dkr.ecr.eu-west-1.amazonaws.com/my-image:latest
Also update your Lambda with the new image:
aws lambda update-function-code \
--function-name my-lambda \
--image-uri 123456789.dkr.ecr.eu-west-1.amazonaws.com/my-image:latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With