Giter Site home page Giter Site logo

Comments (11)

justintilson avatar justintilson commented on May 28, 2024 3

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/

from aws-sam-typescript-layers-example.

Envek avatar Envek commented on May 28, 2024

That's weird! I don't remember such nasty behavior.

What is your SAM CLI version? It may be some SAM CLI bug…

from aws-sam-typescript-layers-example.

Patrick-Erichsen avatar Patrick-Erichsen commented on May 28, 2024

Hey @Envek sorry for the delay, I didn't see your reply come through.

$ sam --version

SAM CLI, version 1.29.0

from aws-sam-typescript-layers-example.

kurkle avatar kurkle commented on May 28, 2024

+1

sam --version  
SAM CLI, version 1.23.0

Edit: No change after updating to 1.31.0
Edit2: aws/aws-sam-cli#1630 (comment)

from aws-sam-typescript-layers-example.

tmbs avatar tmbs commented on May 28, 2024

+1

~ sam --version
SAM CLI, version 1.31.0
~ sw_vers
ProductName:	macOS
ProductVersion:	11.6
BuildVersion:	20G165

from aws-sam-typescript-layers-example.

jettandres avatar jettandres commented on May 28, 2024

+1 also. I'm kinda new to AWS SAM. Thank you sir @Envek for the ts template

~ sam --version        
SAM CLI, version 1.33.0

from aws-sam-typescript-layers-example.

semmgeorge avatar semmgeorge commented on May 28, 2024

+1
SAM CLI, version 1.29.0

from aws-sam-typescript-layers-example.

moretalk avatar moretalk commented on May 28, 2024

+1
SAM CLI, version 1.35.0

from aws-sam-typescript-layers-example.

ahurlburt avatar ahurlburt commented on May 28, 2024

Seems like the workaround for

--warm-containers=EAGER

Does stop the containers rebuilding the layer each time. This is interesting as the docs (cli ref) imply there would be no difference between EAGER and LAZY with regards to layer rebuilding.

While this is helpful it's not great since a lot of times I am only testing a subset of lambdas and don't need the others to invoke at all (or build). Warming all of them still slows down dev process which is what sam local is intended to help with.

This related ticket implies to solve this one would need to publish the lambda and then reference via ARN: aws/aws-sam-cli#1630

IMO this isn't really a great solution since i want SAM to build the layer for me. I use sam so i can have everything in one place and a reproducible build.

I believe the reason to rebuild the layer is because sam needs to check if anything changed. However, i think practically speaking it would be a better solution to assume the layers do not change like the templates and in the event of a layer update sam local would need to be restarted. I think realistically most people want watch type behaviour for their lambda code and not so much the layers which is either shared libs or dependencies.

I also get a lot of errors using the EAGER warm flag, once I start making changes to the code some of the containers don't seem to exit properly and it causes sam local to crash. Then i need to start everything up again which leads me back to why I don't like having to warm everything to avoid the lambda layer rebuild...

from aws-sam-typescript-layers-example.

Envek avatar Envek commented on May 28, 2024

This is great research, @ahurlburt!

Please open issue in https://github.com/aws/aws-sam-cli with this text so SAM CLI developers can be aware of it and hopefully will fix it some day.

from aws-sam-typescript-layers-example.

ahurlburt avatar ahurlburt commented on May 28, 2024

@Envek done: aws/aws-sam-cli#3725

Maybe people coming across this can upvote :)

from aws-sam-typescript-layers-example.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.