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.

Adding Lambda Layer to existing function clears "dependsOn" in backend-config.json

See original GitHub issue

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug Adding Lambda Layer to existing function clears “dependsOn” in backend-config.json

Amplify CLI Version 4.24.2

To Reproduce

  1. Create new Amplify project (I followed getting started for JavaScript)
  2. amplify add api (GraphQL, default settings)
  3. amplify add function (NodeJS, Hello World Function).
  4. amplify add function (create new Layer).

At this moment function is not using the layer. This is backend-config.json

"testclilambda6938ce0a": { "build": true, "providerPlugin": "awscloudformation", "service": "Lambda", "dependsOn": [ { "category": "api", "resourceName": "testclilambda", "attributes": [ "GraphQLAPIIdOutput", "GraphQLAPIEndpointOutput" ] } ] },

  1. amplify update function (add the layer created in step 4 to the function) backend-config.json is now:

"testclilambda6938ce0a": { "build": true, "providerPlugin": "awscloudformation", "service": "Lambda", "dependsOn": [ { "category": "function", "resourceName": "myLayer", "attributes": [ "Arn" ] } ] }

Dependency on API dissapeared. If we push the Lambda now, environment variable will not have GraphQL API endpoint and Id.

Expected behavior Adding the layer should add to existing dependsOn, not replace them.

Screenshots This is what ENV variables look like after the deployment:

image

Desktop (please complete the following information):

  • OS: Windows 10
  • Node Version. v12.17.0

Additional context

Here’s a question: How to rebuild my function - i.e. eve after manually updating backend-config.json - when deployed, the function still does not have environemtent variables set?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
jhockettcommented, Jul 24, 2020

This is a bug with amplify update function.

The current workaround to update a function without losing dependsOn data, is to always answer yes to “Do you want to update the Lambda function permissions to access other resources in this project?” and confirm any existing permissions. Then you can add a Lambda layer or schedule invocation without it overwriting data in the dependsOn array.

0reactions
github-actions[bot]commented, May 26, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using layers with your Lambda function - AWS Documentation
Open the Functions page of the Lambda console. · Choose the function to configure. · Under Layers, choose Add a layer · Under...
Read more >
Functions - Reuse code & assets using layers - Amplify Docs
Use Amplify CLI's Lambda layer capability to reuse code & assets across functions. ... or add layers to an existing function using amplify...
Read more >
Building an i18n serverless video resource platform with AWS ...
To create a custom resource you'll need to modify amplify/backend/backend-config.json to let the Amplify CLI know about your new resources.
Read more >
AWS Cloud9: Referencing Lambda Layer Locally
To make the environment "cleaner" I have opted to use lambda layers to specify the function's dependencies. By doing this, I have removed...
Read more >
How to add custom resources to AWS Amplify. Add an SQS ...
Let's add an SQS queue that triggers lambda. ... was added by Amplify you can reference it in a dependsOn block in the...
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