amplify-cli
amplify-cli copied to clipboard
Cannot add new environment with deleted lambda-layer
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
18.15.0
Amplify CLI Version
12.11.1
What operating system are you using?
Windows
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No manual changes made.
Describe the bug
When I issued an amplify add env
, followed by an amplify push
as described here, my push fails with the following message:
Lambda layer myprojectExampleLayer is missing a state file. Try running "amplify pull --restore". If the issue persists, recreating the layer is the best option. Ensure your layer content is backed up!
It is important to note: myprojectExampleLayer was created and removed many, many months ago. It no longer exists. It was removed using amplify function remove
(as documented here).
I also noticed in the amplify-push, that it is listed in the push:
Current Environment: test
┌──────────┬───────────────────────────────┬───────────┬───────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Api │ myproject │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Function │ MyProjectRealFunction1 │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Function │ MyProjectRealFunction2 │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Function │ myprojectExampleLayer │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Function │ myprojectRealExistingLayer │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Storage │ MyProject │ Create │ awscloudformation │
├──────────┼───────────────────────────────┼───────────┼───────────────────┤
│ Auth │ myprojectde4504b4 │ Import │ awscloudformation │
└──────────┴───────────────────────────────┴───────────┴───────────────────┘
√ Are you sure you want to continue? (Y/n) · yes
-- but it should not be.
I have also noticed (with respect to the error msg), that it complains there's no amplify.state
file: My Lambda-layer (which works) does not have an amplify.state
file, however all my functions do have that file. So it may be looking for a file that never existed.
NOTE: This is preventing me from creating an env, and thus releasing software, and is therefore extremely important to me. 🙂
(My project name was replaced with "MyProject", in the appropriate case, in the above logs.)
Expected behavior
I expect the push to succeed.
Reproduction steps
- create an Amplify project
- add an amplify lambda layer.
- remove it.
- try to add a new environment.
Project Identifier
No response
Log output
# Put your logs below this line
Lambda layer bgtalentAILayer is missing a state file. Try running "amplify pull --restore". If the issue persists, recreating the layer is the best option. Ensure your layer content is backed up!
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
Session Identifier: b98301c2-ae5c-4b73-9c66-141fe6b54542
Additional information
No response
Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Manually removing the layer from the amplify-meta.json
worked.
So the bug is that it is placed there in the first place.
Hey @DarylBeattie, thank you for reaching out. Do you observe the layer when running amplify status
from the env where the add env was run?
if you pull the backend environment into a empty directory outside your existing project using amplify pull --appId <app-id> --envName <env-name>
, do you observe reference to lambda layer?
Hi @ykethan , no it doesn't list it there when I do amplify status
. It was only there when I tried to do the amplify-push after creating the new env.
As for pulling the backend into an empty dir outside my env............ i haven't tried that yet. I'm not sure I have time to try it. 😐
@DarylBeattie could you try running amplify push with --force
? this should update the current-cloud-backend
and remove any reference to the layer.
Additionally, could you check if the team-provider-info.json
file has any references to the function layer.
Yes I obviously tried that pretty much first thing.
In the end I had to remove the mention of the layer from amplify-meta.json
in order for it to work.
Glad to hear you were able to mitigate the issue by removing the reference in the amplify-meta.json
, it appears current-cloud-backend
had a reference to this resource.
Closing this issue.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.