Unable to remove Lambda layer
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 Added a Lambda layer to my project, added a lambda function and configured it to use the layer. Updated function to remove lamba layer config and then tried to remove the layer, get error: Resource cannot be removed because it has a dependency on another resource
Amplify CLI Version 4.34.0
To Reproduce add lambda layer add function and configure to use layer push update function to not use layer push try remove layer and error appears
Expected behavior expect layer to be removed
workaround for this bug:
- edit backend-config.json and remove the layer as dependency from the function
- amplify env checkout
- amplify remove function & delete the layer -amplify push will then delete the layer
if you do amplify update function and unselect the layer from the function configuration, amplify does NOT remove the dependency for the function layer
@frankclaassen Did you try to push after you removed it from the function?
@ammarkarachi yes, when I do the push is when I get the error
Just a bit of extra info. In my case I got it to work without having to remove the function. If you edit these files, removing references to the layer in your function's dependencies, the layer can be properly deleted.
- backend-config.json
- amplify-meta.json
- function-cloudformation-template
I ran into exactly the same problem and could not solve it. I manually removed dependsOn items in backend-config.json but it did not work. It would be great if this problem is not forgotten.
The solution finally solved the problem:
- Create backups of the code in the lambda functions.
- Remove all functions depending on the lambda layer by
amplify remove function. - Remove the lambda layers by
amplify remove function. - Create lambda functions again.
👋 Hi, this issue was referenced in the v4.50.0 release!
Check out the release notes here https://github.com/aws-amplify/amplify-cli/releases/tag/v4.50.0.
This has been addressed in the latest version of the CLI
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.