Can not remove AWS Amplify Auth

Viewed 640

I have a web app using the following amplify resources: Auth API Function Hosting

I have been having issues with the Auth service giving the following network error when going through the Auth0 flows: error message in the headers:

x-amzn-errormessage: IdentityPool 'us-east-2:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found.

Error message in console: POST https://cognito-identity.us-east-2.amazonaws.com/ 400

So I am trying to completely remove the Auth section and try and build it again from scratch.

However, when I run:

amplify remove auth

it removes the Auth in my local code, but then won't allow me to "amplify push" or "amplify publish" because the auth service can not be found ‍♂️‍♂️‍♂️ and I get this message:

Template error: instance of Fn::GetAtt references undefined resource auththisismyappg986421b An error occurred during the push operation: Template error: instance of Fn::GetAtt references undefined resource auththisismyappg986421b

Anyone know how to solve this? or advice on how to get AWS Amplify - React - React Router (using protected routes) to all play along nicely?

1 Answers

Do you have any other resources that depend on auth? (api, storage, etc.) If you do, when you do remove auth you get this warning:

You have configured resources that might depend on this Cognito resource.  Updating this Cognito resource could have unintended side effects.

Judging from you message you might have an API that depends on your Auth. Look at amplify/api/YOURAPI/parameters.json, you should have

   {
      "AppSyncApiName": "YOURAPI",
      "AuthCognitoUserPoolId": {
        "Fn::GetAtt": [
          "auththisismyappg986421b",
          "Outputs.UserPoolId"
        ]
      }
    }

Therefore a dependency to your deleted auth still exists and Amplify does not like that.

What you can do is create your new auth from scratch, then you'll get a new userPoolID let's say auththisismyappgXXXXXXX and replace every instances of auththisismyappg986421b with auththisismyappgXXXXXXX.

Edit: by the way if anyone has a way to do it more cleanly through amplify CLI that would be nice :)

Related