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

aws_lambda: Only update Docker image based Lambdas when changes occur #23038

Closed
2 tasks
DFEvans opened this issue Nov 22, 2022 · 2 comments
Closed
2 tasks

aws_lambda: Only update Docker image based Lambdas when changes occur #23038

DFEvans opened this issue Nov 22, 2022 · 2 comments
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda duplicate This issue is a duplicate. feature-request A feature should be added or improved.

Comments

@DFEvans
Copy link

DFEvans commented Nov 22, 2022

Describe the feature

cdk deploy is pretty insistent on pushing new Docker images and updating Lambdas every time it is run - even if the contents of the Docker images haven't changed.

CDK could instead only push new images and Lambda updates when changes have occurred, reducing the amount of deployment work that is done.

Use Case

We have a CDK stack with a few dozen Lambdas, defined via aws_lambda.DockerImageCode.from_image_asset, all pointing to a local Dockerfile.

Our CI/CD system currently takes 10-15 minutes to run cdk deploy, mostly spent on updating all defined Lambdas with every deployment, regardless of whether a new image needed to be built or not. This is despite caching the cdk.out directory and pushing/pulling the Docker images for the Lambdas to an external repository as part of the build process.

While Docker realises that there are no changes (i.e. it outputs CACHED for all steps in the Dockerfile, both when running docker build and cdk deploy), it has proven challenging to stop CDK from pushing the images as if they were new each time. It appears that CDK is unable to determine that no changes need to be pushed.

If CDK could selectively update Lambdas, this would significantly improve our deploy time - often, only a single Lambda is affected and needs updating.

Proposed Solution

CDK caches, stores, or references Docker images in some way which mean that identical images (at least, as seen by Docker) do not get re-submitted as a new version of the Lambda each time.

Other Information

A potential alternative is that we build the Docker images outside of CDK, pushing them to ECR, and passing the tags through to CDK. However, this is a very heavyweight solution that requires us to re-implement much of the Docker image management that CDK undertakes.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.44.0

Environment details (OS name and version, etc.)

CI/CD workers running Ubuntu-20.04

@DFEvans DFEvans added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 22, 2022
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Nov 22, 2022
@peterwoodworth
Copy link
Contributor

Thanks for the request, we're already tracking this feature request here 🙂

@peterwoodworth peterwoodworth added duplicate This issue is a duplicate. and removed needs-triage This issue or PR still needs to be triaged. labels Nov 22, 2022
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda duplicate This issue is a duplicate. feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

3 participants