I had a problem with a Cognito resource and somehow my local code got out of sync with the pushed version. I ended up deleting the stack on the AWS account and cleared out the resources. Is there a way to re-push from the local? I fear that an 'amplify init' reset what I've already configured locally.
Any recommendations on best way to recover?
Could you clarify the following
v0.1.27
Yep, removed everything via AWS console by deleting the stack, then manually cleaning up what the stack(s) couldn't do (were out of sync with). For example, I had set the domain on my user pool and the stack couldn't delete it with that set.
Maybe another way to describe what I want to do is: if I start with a clean AWS account and a clone of my git repo that has the amplify backend and my app code (React), how can I run it? amplify init wants to recreate most of what exists in the paramters/api-params files...
You could try these steps manually to recover. ymmv based on how cleanly the stack was deleted.
amplify init
in a new folder init
succeeds, copy everything in the amplify/#current-cloud-backend
of your corrupted project to backend
of the new project you just created.amplify/backend/amplify-meta.json
of the newly created projectproviders
from amplify/#current-cloud-backend/amplify-meta.json
from the newly created project and paste it on to amplify/backend/amplify-meta.json
s providers
sectionClosing the issue. Re-open if the recovery step didn't work
This isn't resolved. Still getting Project stack doesn't exist
Chiming in here in case anyone else runs into this: the CloudFormation details are scattered in a lot of places, it's best to just rename your ./amplify
folder (maybe ./amplify-old
) and run amplify init
again within your project and walk through the prompts to set up a new stack. Then amplify add <service>
again for the various services. If you are using API/GraphQL, re-add your schemas when prompted (from your backup). amplify push
when you're done to rebuild the stack.
I follow the below steps to tear down my environment on AWS, whilst keeping my local code intact. Basically, I just delete the current environment I'm on, and re-create it.
Delete the aws-export.js
file so it doesn't cause issues when we re-create our environment. You may want to back it up.
Create & switch to a temporary environment (called temp
) before we can delete the current one. We can do this by running the below command:
amplify init
Answer the following for the prompt:
? Do you want to use an existing environment? (Y/n) ---> n
? Enter a name for the environment ---> temp
# ... The rest can be left as default
(Optional) After running amplify init
, it'd switch you to the new environment. You can check your list of environments, and the currently checked out environment via the amplify env list
command.
Remove the existing environment with the below command. This would remove the associated cloud resources as well.
amplify env remove <YourEnvironmentName>
<YourEnvironmentName>
should be replaced by whatever your environment is. By default, it's dev
.
Now that the environment is deleted, run the below command to re-create it.
amplify init
Answer the following for the prompt:
? Do you want to use an existing environment? (Y/n) ---> n
? Enter a name for the environment ---> dev (or whatever the name is the environment you've deleted)
# ... The rest can be left as default
Now that we're switched back to our original environment & deleted the cloud resources, we can remove the temporary environment.
amplify env remove temp
Finally, we push the cloud resources for our environment so our AWS resources is re-created.
amplify push
Hit this today, my mental model of what is safe to do and what isn't just isn't solid enough in my head yet and its frustrating that I only seem to find out the boundaries when I hit them. A warning site or a helping hand to pull be back from the brink would be nice. As a result I think the CLI needs strengthening to make it safer to experiment, do stupid stuff for stupid people like me.
In my case I deleted some tables from DynamoDB which I'd removed from my schema but hadn't yet pushed those changes.
Misunderstanding No. 1: I thought that if I removed (or renamed) a table from the schema it wouldn't delete it in DynamoDB as that would be a destructive action, I could be losing data. I understood it that I would have to go in and clean up by hand. Is that not the case anymore? In this case I didn't care about losing data so deleted the table manually.
Misunderstanding No. 2: That if Amplify can't find a table when pushing (that it doesn't need anymore so shouldn't really care) it could just skip it (with a warning "Hey, I wanted to delete this for you but it appears to already be gone!"). Instead it just blows up and cancels the whole push and leaves me in an unknown state.
This is frustrating when developing but also adds to the terror in your belly about when this stuff goes live. Sure we fly a bit fast and loose in dev mode but I would like to think I can get it back up and running easily if something went wrong in production but having to do the "config/init shuffle!" described by @deltoss above doesn't really fill me with the warm fuzzies in my belly...more likely to bring me out in a cold sweat.
Currently when I've messed up my schema and get the dreaded red lines of doom when I push its difficult to know how to even begin to get back to known state. Need a way to safely "put it right" without having to resort to the "init shuffle".
Most helpful comment
I follow the below steps to tear down my environment on AWS, whilst keeping my local code intact. Basically, I just delete the current environment I'm on, and re-create it.
Delete the
aws-export.js
file so it doesn't cause issues when we re-create our environment. You may want to back it up.Create & switch to a temporary environment (called
temp
) before we can delete the current one. We can do this by running the below command:Answer the following for the prompt:
(Optional) After running
amplify init
, it'd switch you to the new environment. You can check your list of environments, and the currently checked out environment via theamplify env list
command.Remove the existing environment with the below command. This would remove the associated cloud resources as well.
<YourEnvironmentName>
should be replaced by whatever your environment is. By default, it'sdev
.Now that the environment is deleted, run the below command to re-create it.
Answer the following for the prompt:
Now that we're switched back to our original environment & deleted the cloud resources, we can remove the temporary environment.
Finally, we push the cloud resources for our environment so our AWS resources is re-created.