RuntimeDependenciesLayer rebuilding on every API request
See original GitHub issueFirst of all, thank you @Envek and others for both the great writeup at https://evilmartians.com/chronicles/serverless-typescript-a-complete-setup-for-aws-sam-lambda and for this template repo.
This is my first time using AWS SAM in general, and it’s been tricky with Typescript.
Problem
When running sam local start-api
, every request I make to http://127.0.0.1:3000/ triggers a rebuild of the dependency layer.
Steps to reproduce
- Clone fresh copy of repo and walk through the setup
sam local start-api
- Visit http://127.0.0.1:3000/
The first visit will build the image as expected.
When refreshing the browse, based on this comment, I would expect the image not to rebuild since no source code would have changed.
However, on each request, the image appears to be rebuilt with the following log line:
RuntimeDependenciesLayer is a local Layer in the template
The time it takes to rebuild this image makes it difficult to develop my frontend.
The workaround I have right now is to just point my frontend at my dev
environment in AWS, but I’d prefer to be able to run both front & backend locally.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (2 by maintainers)
Top GitHub Comments
One way I found that changes this behavior is to include the
--warm-containers=EAGER
flag when starting your local SAM API. Example:sam local start-api --docker-network your-network --env-vars=env.json --warm-containers=EAGER
From: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-local-start-api.html with some more relevant tidbits here: https://aws.amazon.com/blogs/compute/working-with-aws-lambda-and-lambda-layers-in-aws-sam/
@Envek done: https://github.com/aws/aws-sam-cli/issues/3725
Maybe people coming across this can upvote 😃