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

"Stack [...] already exists, please report this issue to amplify-cli github" error and amplify console build timeout #11120

Closed
5 tasks done
hisham opened this issue Oct 5, 2022 · 22 comments · Fixed by #11137
Labels
bug Something isn't working p1 platform-init Issues related to initializing a new Amplify project

Comments

@hisham
Copy link
Contributor

hisham commented Oct 5, 2022

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • 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.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

14

Amplify CLI Version

10.2.2

What operating system are you using?

Amazonlinux

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

no

Amplify Categories

Not applicable

Amplify Commands

init

Describe the bug

In amplify-console, since Oct. 3, we have repeatedly been getting build timeouts and the following error:

[31mAn error occurred when creating the CloudFormation stack�[39m
2022-10-05T20:46:14.908Z [INFO]: 🛑 Stack [amplify-ess-app-abdulladev-215910] already exists
2022-10-05T20:46:14.908Z [INFO]: Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'

In my local workstation I'm able to do an amplify push with no issues, although I have not tested 'amplify init'. I created aws-amplify/amplify-hosting#3017 since this seems to be amplify-console issue but I have no response so far.

Since the logs are telling me to send this report to you and file an issue I'm doing so here. My project identifier (when I run amplify diagnose in my local workstation) is 3def1a2bd59d61900f734d59f169a578.

Expected behavior

Backend build should complete successfully, and if there is error it should fail immediately rather than waiting 30 min and timing out.

Reproduction steps

Do any deployment in amplify console env d2d6ty1wlg8jch

GraphQL schema(s)

# Put schemas below this line

Project Identifier

3def1a2bd59d61900f734d59f169a578

Log output

# Put your logs below this line
2022-10-05T20:46:12.838Z [WARNING]: Everything up-to-date
2022-10-05T20:46:12.844Z [INFO]: # Getting Amplify CLI Cloud-Formation stack info from environment cache
2022-10-05T20:46:12.851Z [INFO]: # Start initializing Amplify environment: abdulladev
                                 # Initializing new Amplify environment: abdulladev (amplify init)
2022-10-05T20:46:14.076Z [INFO]: �[33mNote: It is recommended to run this command from the root of your app directory�[39m
2022-10-05T20:46:14.791Z [INFO]: �[0mAmplify AppID found: d2d6ty1wlg8jch. Amplify App name is: ess-app�[0m
2022-10-05T20:46:14.904Z [INFO]: �[31m�[39m
                                 �[31mAn error occurred when creating the CloudFormation stack�[39m
2022-10-05T20:46:14.908Z [INFO]: 🛑 Stack [amplify-ess-app-abdulladev-215910] already exists
2022-10-05T20:46:14.908Z [INFO]: Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'
2022-10-05T21:15:16.557Z [INFO]: ExpiredToken: The security token included in the request is expired
                                 at Request.extractError (/snapshot/repo/build/node_modules/aws-sdk/lib/protocol/query.js:50:29)
                                 at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
                                 at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
                                 at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)
                                 at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)
                                 at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)
                                 at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10
                                 at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)
                                 at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)
                                 at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
                                 at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
                                 at Request.emit (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:686:14)
                                 at Request.transition (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:22:10)
                                 at AcceptorStateMachine.runTo (/snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:14:12)
                                 at /snapshot/repo/build/node_modules/aws-sdk/lib/state_machine.js:26:10
                                 at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:38:9)
                                 at Request.<anonymous> (/snapshot/repo/build/node_modules/aws-sdk/lib/request.js:688:12)
                                 at Request.callListeners (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
                                 at callNextListener (/snapshot/repo/build/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
                                 at IncomingMessage.onEnd (/snapshot/repo/build/node_modules/aws-sdk/lib/event_listeners.js:335:13)
                                 at IncomingMessage.emit (events.js:412:35)
                                 at IncomingMessage.emit (domain.js:475:12)
                                 at endReadableNT (internal/streams/readable.js:1334:12)
                                 at processTicksAndRejections (internal/process/task_queues.js:82:21) {
                                 code: 'ExpiredToken',
                                 time: 2022-10-05T21:15:16.554Z,
                                 requestId: '6bdc832a-e716-48b2-b468-2c5e68751cb1',
                                 statusCode: 403,
                                 retryable: true
                                 }

Additional information

No response

@conorw
Copy link

conorw commented Oct 6, 2022

I'm getting the same build issues since October 3rd when using github actions i.e. I can manually deploy on my local workstation but the "amplify init" commands are failing in the CICD process: either the current stack is not found and it tries to create a new stack or we get the message above (Stack [...] already exists).

@josefaidt josefaidt added the pending-triage Issue is pending triage label Oct 6, 2022
@conorw
Copy link

conorw commented Oct 6, 2022

Some additional information.
If we supply the appId in the amplify init script it will indicate that the stack already exists.
If we omit the appId, it creates a new amplify app and environment.

Strangely, If we run the script locally, it picks up the current amplify app/stack and works as expected i.e. it just initializes with the existing amplify app.

Here is the .sh script we are using for the cicd process

#!/bin/bash
set -e
IFS='|'
NOTIFICATIONSCONFIG="{"Pinpoint":{"FCM":{"Enabled":true,"ApiKey":"${FCM_API_KEY}"}}}"
AWSCLOUDFORMATIONCONFIG="{
"configLevel":"project",
"useProfile":false,
"profileName":"default",
"accessKeyId":"${AWS_ACCESS_KEY_ID}",
"secretAccessKey":"${AWS_SECRET_ACCESS_KEY}",
"region":"us-east-1"
}"
AMPLIFY="{
"projectName":"myproject",
"envName":"${ENV}",
"defaultEditor":"code"
}"
FRONTEND="{
"frontend":"ios"
}"
PROVIDERS="{
"awscloudformation":$AWSCLOUDFORMATIONCONFIG
}"
CODEGEN="{
"generateCode":true,
"codeLanguage":"typescript",
"fileNamePattern":"graphql/**/*.graphql",
"generatedFileName":"API.ts",
"generateDocs":true,
"maxDepth":2
}"
AUTHCONFIG="{
"appleAppId":"${AMPLIFY_APPLE_ID}",
"googleAppIdUserPool":"${AMPLIFY_GOOGLE_CLIENT_ID}",
"googleClientId":"${AMPLIFY_GOOGLE_CLIENT_ID}",
"googleAppSecretUserPool":"${AMPLIFY_GOOGLE_CLIENT_SECRET}"
}"

CATEGORIES="{
"auth":$AUTHCONFIG,
"notifications":$NOTIFICATIONSCONFIG
}"
amplify init
--amplify $AMPLIFY
--categories $CATEGORIES
--frontend $FRONTEND
--providers $PROVIDERS
--codegen $CODEGEN
--yes

@josefaidt
Copy link
Contributor

Hey @hisham 👋 thanks for raising this! It appears you and @conorw both began to experience this when Amplify CLI version 10.2.1 was released, however as I begin to investigate this in more depth a patch was released yesterday. Do you also experience this using CLI version 10.2.2?

@josefaidt josefaidt added the platform-init Issues related to initializing a new Amplify project label Oct 6, 2022
@josefaidt
Copy link
Contributor

Hey folks using CLI v10.2.1 I cloned an existing project from git, attempted a headless init, and was able to reproduce this issue. After switching to pull, however, I was able to successfully pull the project and initialize it locally.

➜  amplify init --envName next --yes
Note: It is recommended to run this command from the root of your app directory
Using default provider  awscloudformation

Deploying resources into next environment. This will take a few minutes. ⠙
Deploying root stack 9071 [ ---------------------------------------- ] 0/4

An error occurred when creating the CloudFormation stack
🛑 Stack [amplify-9071-next-153423] already exists

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the prDeploying resources into next environment. This will take a few minutes. ⠹
Deploying root stack 9071 [ ---------------------------------------- ] 0/4
^C⏎                                                                                                         ^Aborted!


➜  amplify pull --appId dbaciat8nbvr7 --envName next --yes
Amplify AppID found: dbaciat8nbvr7. Amplify App name is: 9071
Backend environment next found in Amplify Console app: 9071
✔ Successfully pulled backend environment next from the cloud.
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
✅ 

After upgrading to v10.2.2 I was not able to initialize my project with the same headless init command.

➜  amplify version
10.2.2

➜  amplify init --envName next --yes
Note: It is recommended to run this command from the root of your app directory
Using default provider  awscloudformation

Deploying resources into next environment. This will take a few minutes. ⠙
Deploying root stack 9071 [ ---------------------------------------- ] 0/4

An error occurred when creating the CloudFormation stack
🛑 Stack [amplify-9071-next-153423] already exists

Resolution: Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the prDeploying resources into next environment. This will take a few minutes. ⠧
Deploying root stack 9071 [ ---------------------------------------- ] 0/4
^C⏎                                                                                                         ^Aborted!

Marking this as a bug, as a workaround please replace init with pull in your headless scripts, or downgrade to Amplify CLI version 10.0.0.

@josefaidt josefaidt added bug Something isn't working and removed pending-triage Issue is pending triage labels Oct 6, 2022
@conorw
Copy link

conorw commented Oct 6, 2022

@josefaidt thanks for taking a look.
I can confirm that this is happening on 10.2.2
Thanks for the "amplify pull" workaround, can we still supply the auth params etc using the pull command?

image

@josefaidt
Copy link
Contributor

Hey folks I will note I was not able to reproduce this in Amplify Hosting, but this is a bug with headless init nonetheless

image

Thanks for the "amplify pull" workaround, can we still supply the auth params etc using the pull command?

@conorw I don't believe headless pull will accept those inputs, however I did notice I'm able to run headless init after pulling the project. Could you perhaps run a lean headless pull command (e.g. amplify pull --appId <your-app-id> --envName <env-name> --yes), then run your headless init script?

@conorw
Copy link

conorw commented Oct 6, 2022

cool. thanks @josefaidt i will give both a try.

@hisham
Copy link
Contributor Author

hisham commented Oct 6, 2022

I downgraded amplify cli to 10.0.0 in Amplify Console and now the build succeeds.

@josefaidt
Copy link
Contributor

josefaidt commented Oct 6, 2022

For fix, reproduction steps are:

  1. clone https://github.com/josefaidt/9071 (or create some app)
  2. run amplify init and amplify push to create the initial app
  3. in a separate directory, clone https://github.com/josefaidt/9071 again
  4. run amplify init --envName dev --yes
  5. observe error

@conorw
Copy link

conorw commented Oct 6, 2022

@josefaidt I can confirm that performing amplify pull before init, is successfully working as a workaround, thanks.

@josefaidt
Copy link
Contributor

Hey @conorw glad to hear that you're up and running! Apologies for the hurdle, the team is actively investigating 🙂

@josefaidt
Copy link
Contributor

For reference, the non-headless amplify init flow is also impacted when attempting to initialize an existing environment
image

@pedrolucasD
Copy link

Hello guys.
We had the same problem here at the company I work for and we managed to solve it by downgrading to version 10.0.0.
Thanks for sharing the information.

@swaminator
Copy link
Contributor

@hisham what do you have in your amplify.yml?

@hisham
Copy link
Contributor Author

hisham commented Oct 6, 2022

Hi @swaminator - I just sent the amplify.yml and related contents to [email protected]

@vidhyasagarj
Copy link

I am still facing the issue, when is this expected to get updated

@golbergtx
Copy link

Me too

@josefaidt
Copy link
Contributor

Hey @vidhyasagarj would you mind opening a separate bug report if you are experiencing this?

@webjay
Copy link

webjay commented May 11, 2023

I also get this error on Vercel with 12.0.0, 11.1.1 and with 10.0.0

@KOSSOKO
Copy link

KOSSOKO commented Nov 2, 2023

I'm also facing the same issue

@jkruse14
Copy link

jkruse14 commented May 9, 2024

This is still an issue with amplify 12.10.1

the amplify pull ... workaround continues to work.

@nelmasry
Copy link

I'm using the latest version 12.13.0 and still having the same issue, tried downgrading but the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p1 platform-init Issues related to initializing a new Amplify project
Projects
None yet
Development

Successfully merging a pull request may close this issue.