Tommy
Tommy

Reputation: 1034

AWS Amplify: How to recreate manually deleted CloudFormation stacks

I built an Amplify sample application following this workshop. Afterwards, I manually deleted CloudFormation stacks (from the AWS console - selected root stack and executed delete stack action) hoping that I can rebuild them using amplify push. Unfortunately, amplify reports no changes and do not rebuild stacks. Is there a way to force amplify to provision the resources?

Upvotes: 8

Views: 11746

Answers (4)

SoloWolf93
SoloWolf93

Reputation: 1089

After many research i have found a solution

If you deleted backend manually. you can re-create it again by using this command

amplify init --appId YOUR_APP_ID

If you have access to the AWS console and can see the App ARN field (in general settings), you can find the AppId:

arn:aws:amplify:eu-west-1:xxxxxxxxxx/APPID

Before initialising you have to delete stacks

After that just go with flow of amplify init, after that it will create backend and all as fresh start

And if you want to delete that app you can call amplify delete in cli it will delete from cloud and locally

Upvotes: 0

rcambrj
rcambrj

Reputation: 602

Amplify seems to keep information about what's hosted in AWS in amplify/team-provider-info.json. Inside this file should be JSON object with keys matching your environment names. If you leave your environment name's entry in this file and run amplify init, if you use the same environment name, you will most likely see a failure.

By removing the environment matching the one that you removed in AWS, amplify will forget about that environment's CloudFormation stack. Now you can run amplify init again, and use the same environment name, with success.

Upvotes: 3

gildniy
gildniy

Reputation: 3913

If you delete a function or an API which other resources depend on, this could lead to the push to fail. So what I usually do, is to recreate the same function or API and push it again. It's a provisional hack I use, but I think there could be a better one.

Upvotes: 1

Yathi
Yathi

Reputation: 386

amplify cli checks diff between amplify/#current-cloud-backend and amplify/backend folder inside your project. It doesn't check what is currently deployed in the cloud.

Since you have deleted the root stack, even if there were any changes to push, it would fail as the stack is missing. To recover from this error you can run amplify init and and when asked Do you want to use an existing environment? select No. This will recreate the root stack and will allow you to push your changes.

PS: Multi environment support is available in amplify cli version 1 and above. If its pre v1 init command won't work

Upvotes: 9

Related Questions