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

New backend references resources from deleted backend with same name

Open adam-nygate opened this issue 1 year ago • 4 comments

Before opening, please confirm:

  • [X] I have checked to see if my question is addressed in the FAQ.
  • [X] I have searched for duplicate or closed issues.
  • [X] I have read the guide for submitting bug reports.
  • [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.

App Id

d1dsr14iqx52pk

AWS Region

us-east-2

Amplify Hosting feature

Backend builds, Backend environments

Frontend framework

Vue

Next.js version

N/A

Next.js router

N/A

Describe the bug

The backend environment of a new environment references resources from a deleted backend with the same name.

Expected behavior

A new environment should not reference resources from a different environment, even an environment with the same name (that was deleted).

Reproduction steps

  1. Create a new environment called main
  2. Import an auth resource on this new environment (e.g auth1234abcd) and deploy it to the backend
  3. Delete the environment entirely
  4. Create another new environment with the same name (i.e main)
  5. Import the same auth resource on this new environment but with a different name (e.g. auth1234efgh) and deploy it to the backend (this will succeed)
  6. Make a change to the backend (e.g. add another resource) and let the automated builds deploy the change via the amplify-console.

See the logs for the failure details, I.e:

2023-07-21T18:34:30.250Z [INFO]: [0mAmplify AppID found: xxx amplify App name is: xxx[0m
2023-07-21T18:34:30.289Z [INFO]: [0mBackend environment main found in Amplify Console app: xxx[0m
2023-07-21T18:34:40.970Z [WARNING]: - Fetching updates to backend environment: main from the cloud.
2023-07-21T18:35:00.649Z [WARNING]: - Building resource api/xxx
2023-07-21T18:35:00.651Z [WARNING]: - Building resource auth/auth1234abcd
2023-07-21T18:35:00.698Z [WARNING]: ✔ Successfully pulled backend environment main from the cloud.
2023-07-21T18:35:01.419Z [WARNING]: ✖ There was an error initializing your environment.
2023-07-21T18:35:01.769Z [INFO]: 🛑 Could not initialize categories for 'main': The "path" argument must be of type string. Received undefined

^ note the auth resource being referenced is from the now non-existent environment.

Build Settings

backend:
  phases:
    build:
      commands:
        - envCache --set stackInfo ""
        - amplifyPush --simple

Log output

``` 2023-07-21T18:34:30.250Z [INFO]: [0mAmplify AppID found: xxx amplify App name is: xxx[0m 2023-07-21T18:34:30.289Z [INFO]: [0mBackend environment main found in Amplify Console app: xxx[0m 2023-07-21T18:34:40.970Z [WARNING]: - Fetching updates to backend environment: main from the cloud. 2023-07-21T18:35:00.649Z [WARNING]: - Building resource api/xxx 2023-07-21T18:35:00.651Z [WARNING]: - Building resource auth/auth1234abcd 2023-07-21T18:35:00.698Z [WARNING]: ✔ Successfully pulled backend environment main from the cloud. 2023-07-21T18:35:01.419Z [WARNING]: ✖ There was an error initializing your environment. 2023-07-21T18:35:01.769Z [INFO]: 🛑 Could not initialize categories for 'main': The "path" argument must be of type string. Received undefined ```

Additional information

I've tried instantiating the environment from local (i.e amplify add env && amplify push) and from amplify-console (setting up the branch and backend connection and then letting automated builds deploy the backend).

Initial deploys via the console work but subsequent deploys do not. Local deploys always work (but don't meet our needs).

I've also verified that the envCache does not have references to the resources by accessing the pre-signed s3 object exposed in the builds env.

adam-nygate avatar Jul 21 '23 18:07 adam-nygate