Amplify API GraphQL - Unable to change local API Key with the one generated online

Viewed 786

To update my API key, I used to go on AWS AppSync → Settings and generate a new one.

After that, inside my local app, find and replace my old API key with the new one... Until yesterday this worked fine but now, no matter what I do, when I run amplify status it outputs my old API key.

I also tried amplify update api with no luck. Later I tried amplify pull to see if it updates my local API key with the new one from the web app (AppSync) still no luck.

I already have a valid API key generated online, why I'm not able to update my local API key with the same key?

1 Answers

Try this solution:

  1. open this folder inside your project amplify/backend/<api>/parameters.json

  2. add these lines:

    "APIKeyExpirationEpoch": -1, "CreateAPIKey": -1

  3. From terminal run amplify push.

This should delete the API key from the stack. Now, remove APIKeyExpirationEpoch and CreateAPIKey from parameters.json again, and create a new key using the CLI:

amplify update api

amplify push

With this solution you can renew your API key for 1 year.

Related