question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lambda layer updating when there were no changes

See original GitHub issue

Why does chalice with automatic_layer have to update the lambda layers every time you call deploy? If it knows to use the same deployment package, shouldn’t it know it doesn’t need to update the layer? This method doesn’t really save time like it says in the documentation, because the dependencies are still getting re-deployed.

Example where I run deploy twice:

$ chalice deploy
Creating shared layer deployment package.
Creating app deployment package.
Creating lambda layer: webstack-dev-managed-layer
...
$ chalice deploy
Creating shared layer deployment package.
  Reusing existing shared layer deployment package.
Creating app deployment package.
  Reusing existing app deployment package.
Updating lambda layer: webstack-dev-managed-layer
...

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
res0nat0rcommented, Jun 4, 2021

Also I believe this breaks the shared layers concept outlined in the AWS blog post here.

IE, trying to set a fixed shared layer like so:

{
  "version": "2.0",
  "app_name": "reuse-layer",
  "layers": ["arn:aws:lambda:us-west-2:12345:layer:layerapp-dev-managed-layer:2"],
  "stages": {
    "dev": {
      "api_gateway_stage": "api"
    }
  }
}

Will break upon two subsequent deployments of the same requirements.txt, even though the actual requirements don’t change. Since the :version number will get bumped and the previous version deleted, all of the layer sharing will break, even though the actual layer contents haven’t been modified, so you can’t really point to an 100% known fixed shared layer which you know contains these exact package versions and these versions only, since the version number isn’t fixed.

1reaction
jameslscommented, Jan 11, 2021

Yeah, it seems like that’s an optimization we should be able to make. The main benefits you get now are 1) skipping the pip download process and 2) sharing the layer across multiple lambda functions, but if you just have a single lambda function it really only saves time by skipping the pip download process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using layers with your Lambda function - AWS Documentation
A Lambda layer is a .zip file archive that can contain additional code or other content ... You cannot update functions' layer versions...
Read more >
Calculating when Lambda Layers should be updated
Look at your git file changes (i.e. with PythonGit) and see if any of your layers have changed files. If so, you should...
Read more >
Updating AWS Lambda Function Code when Local Files ...
Updating AWS Lambda Function Code when Local Files Change · 1. Create a Makefile · 2. Publish a New Layer Version when Dependencies...
Read more >
Migration & Backwards Compatibility - Lambda layer behavior ...
Any update to an existing Lambda layer triggers a migration for that layer upon amplify push . Once the layers are migrated, the...
Read more >
terraform-aws-modules/lambda/aws
Create, update, and publish AWS Lambda Function and Lambda Layer - see ... During the plan phase, when using docker, there is no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found