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.

Multi environment lambda layer hard codes environment

See original GitHub issue

Describe the bug I have two environments and have created a new lambda layer. When I add the lambda layer to a function in the first environment, the CFN template for that function injects the current environment’s layer value as a hard coded value from the env it was created in, rather than the environment that the build is/will be occurring in

https://github.com/aws-amplify/amplify-cli/blob/bffaded7351e3bfbcb67fede139b3dab7770eda4/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/lambda-layer-cloudformation-template.ts#L154-L158

Amplify CLI Version 4.29.4

To Reproduce

  1. Create two environments
  2. Add a single lambda layer to both
  3. Add the lambda layer to a function in environment A
  4. Check the output of Layers in function-cloudformation-template.json – the value contains a hard-coded env

Expected behavior The string value should contain a reference to Ref:env to pull the environment value from the current build environment rather than the environment where the layer was added to the function

Desktop (please complete the following information):

  • OS: Mac
  • Node Version. 10.15.3

Additional context

https://github.com/aws-amplify/amplify-cli/blob/bffaded7351e3bfbcb67fede139b3dab7770eda4/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/lambda-layer-cloudformation-template.ts#L154-L158

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:11
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
tomhirschfeldcommented, Jan 7, 2021

@jhockett anything else to share here? Layers are really slowing our productivity down

5reactions
jhockettcommented, Nov 12, 2020

Hi all, we are actively looking into reworking how layer versions work in the CLI, so fixing this issue will likely either coincide or follow that update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deploying AWS Lambda Code In Different Environments
The above steps should help you set up multiple environments in AWS Lambda. We can ensure that the development URL always gets the...
Read more >
Managing a multi-environment serverless architecture in AWS
Multiple stage support in SAM is still unclear and quirky, it seems difficult to manage multiple API Gateway stages and Lambda aliases in...
Read more >
Best practices for working with AWS Lambda functions
Use environment variables to pass operational parameters to your function. For example, if you are writing to an Amazon S3 bucket, instead of...
Read more >
Why you should not use Lambda aliases to define environments
There are many approaches to running Lambdas across logical environments, but you need to be wary of the pitfalls when using aliases.
Read more >
Finding an equivalent of environment variables in AWS ...
I could set a 'LoggingEventBus' environment variable on all the lambda functions that use this layer. But that seems repetitive and error prone....
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