3

We have a server-less stack that relies on multiple AWS Lambdas to perform tasks. To help make code re-usable we have multiple Lambda Layers shared across the Lambdas.

Our issue is, when we make a change to a layer, it creates a new version of the layer. All Lambdas that use this layer do not automatically use the latest version. They are however smart enough to detect that there is a new version and no longer run (throwing an exception that it needs to use the latest layer)

For 50+ Lambdas, The AWS portal has a terrible flow for updating layers. One-by-one, manually open every Lambda, remove the layer, add the new layer etc.

Is there a way to update all Lambdas to use the latest version of all necessary layers using the CLI or some other automated method?

react-dev
  • 213
  • 2
  • 5

2 Answers2

1

Every time you update the layer loop through your Lambda functions and update their config. You can use AWS CLI to do that:

aws lambda update-function-configuration --layers ...

A better way though is to have a CI/CD deployment for your layers and lambdas and have dependencies configured. Whenever a Layer pipeline is updated it should trigger a re-deployment of all the Lambdas that depend on that layer. All modern CI/CD tools can do that - GitLab, Jenkins, GoCD, or even AWS CodePipeline.

That way all you have to do it push new layer code to the git repository and your CI/CD tool will take care of the rest.

Hope that helps :)

MLu
  • 24,849
  • 5
  • 59
  • 86
  • The CLI should save us some time in the short term. In reality this should really be the time to build proper CI/CD pipelines. Thanks. – react-dev Jun 09 '20 at 01:02
0

The AWS Lambda console now supports bulk updates, as of 2022-03-31: AWS Announcement.

Warren Parad
  • 101
  • 2