amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Unable to remove Lambda layer

Open frankclaassen opened this issue 6 years ago • 8 comments

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

frankclaassen avatar Nov 25 '20 05:11 frankclaassen

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 avatar Nov 25 '20 06:11 frankclaassen

@frankclaassen Did you try to push after you removed it from the function?

ammarkarachi avatar Nov 25 '20 16:11 ammarkarachi

@ammarkarachi yes, when I do the push is when I get the error

frankclaassen avatar Nov 25 '20 23:11 frankclaassen

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

half2me avatar Dec 24 '20 09:12 half2me

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:

  1. Create backups of the code in the lambda functions.
  2. Remove all functions depending on the lambda layer by amplify remove function.
  3. Remove the lambda layers by amplify remove function.
  4. Create lambda functions again.

katryo avatar Mar 28 '21 23:03 katryo

👋 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.

github-actions[bot] avatar Apr 27 '21 16:04 github-actions[bot]

This has been addressed in the latest version of the CLI

edwardfoyle avatar Apr 27 '21 16:04 edwardfoyle

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.

github-actions[bot] avatar May 27 '21 17:05 github-actions[bot]