Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add new environment with deleted lambda-layer #13763

Open
2 tasks done
DarylBeattie opened this issue May 5, 2024 · 4 comments
Open
2 tasks done

Cannot add new environment with deleted lambda-layer #13763

DarylBeattie opened this issue May 5, 2024 · 4 comments
Labels
functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage

Comments

@DarylBeattie
Copy link

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

  1. create an Amplify project
  2. add an amplify lambda layer.
  3. remove it.
  4. 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:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@DarylBeattie DarylBeattie added the pending-triage Issue is pending triage label May 5, 2024
@DarylBeattie
Copy link
Author

Manually removing the layer from the amplify-meta.json worked.
So the bug is that it is placed there in the first place.

@ykethan
Copy link
Contributor

ykethan commented May 7, 2024

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?

@ykethan ykethan added functions Issues tied to the functions category pending-response Issue is pending response from the issue author labels May 7, 2024
@DarylBeattie
Copy link
Author

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

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label May 12, 2024
@ykethan
Copy link
Contributor

ykethan commented May 22, 2024

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

@ykethan ykethan added the pending-response Issue is pending response from the issue author label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants