Adding Lambda Layer to existing function clears "dependsOn" in backend-config.json
See original GitHub issueNote: 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
- Create new Amplify project (I followed getting started for JavaScript)
- amplify add api (GraphQL, default settings)
- amplify add function (NodeJS, Hello World Function).
- 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" ] } ] },
- 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:
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:
- Created 3 years ago
- Comments:7 (3 by maintainers)
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 thedependsOn
array.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.