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

Converting from Expired API Key to Cognito causes Cloudformation to fail. #954

Closed
jmgtan opened this issue Feb 27, 2019 · 15 comments
Closed
Assignees
Labels
bug Something isn't working critical-bug Show stopper bug graphql-transformer-v1 Issue related to GraphQL Transformer v1

Comments

@jmgtan
Copy link

jmgtan commented Feb 27, 2019

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
official AWS Amplify Console forum

Describe the bug
Switching to Cognito auth type from an expired API key causes amplify push to fail with the error 404 not found.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new project and use API Key as the auth type
  2. Expire the API key
  3. Convert existing project to Cognito using amplify api update
  4. Execute amplify push
  5. This would cause Cloudformation to fail.

Expected behavior
Auth type to switch to Cognito instead of API key

Screenshots
image

Additional context
Using Amplify for Javascript with React. Using Amplify version 1.1.6

@yuth yuth added question General question graphql-transformer-v1 Issue related to GraphQL Transformer v1 bug Something isn't working critical-bug Show stopper bug labels Feb 27, 2019
@mikeparisstuff
Copy link
Contributor

mikeparisstuff commented Feb 27, 2019

Hello, you can get around this by setting the "APIKeyExpirationEpoch" parameter to -1 in your project's parameters.json file (https://aws-amplify.github.io/docs/cli/graphql#apikeyexpirationepoch). The issue is that the AppSync service deletes API keys when they become invalid which is causing CloudFormation to lose a reference to it. We will make a code change to the GraphQL Transform such that API Keys are never created when you have user pools auth enabled which should solve the problem from this perspective in the future. Thanks for reporting this issue.

@yuth yuth removed the question General question label Feb 27, 2019
yuth added a commit to yuth/amplify-cli that referenced this issue Feb 28, 2019
GraphQL transformer created AppSync API key even if the user had selected Cognito user pool as
authorization type for API. These API keys expire after 7 days and when they do expire, users cant
push changes using cloud formation. Updated transformer not to generate an API key when using
Cognito User Pool

fix aws-amplify#954
@ghost ghost assigned yuth Feb 28, 2019
@ghost ghost added the review label Feb 28, 2019
@jmgtan
Copy link
Author

jmgtan commented Feb 28, 2019

This error also applies if you want to refresh the API Key and your existing one is already expired. The same CloudFormation error occurs.

@mwarger
Copy link
Contributor

mwarger commented Mar 3, 2019

I'm also getting this when I have never used an API key for my API. It just started happening after a push to my branch in Amplify Console today...

03 Mar 2019 19:36:05 GraphQLAPIKey UPDATE_FAILED API key not found: da2-acfmba764zcuzck44ihpmcwye4 (Service: AWSAppSync; Status Code: 404; Error Code: NotFoundException; Request ID: 95d2f4db-3deb-11e9-a479-3bdace7660c9)

mikeparisstuff pushed a commit to mikeparisstuff/amplify-cli that referenced this issue Mar 20, 2019
GraphQL transformer created AppSync API key even if the user had selected Cognito user pool as
authorization type for API. These API keys expire after 7 days and when they do expire, users cant
push changes using cloud formation. Updated transformer not to generate an API key when using
Cognito User Pool

fix aws-amplify#954
mikeparisstuff added a commit that referenced this issue Mar 20, 2019
@kaustavghosh06
Copy link
Contributor

Fix for this has been pushed and released with the latest CLI version 1.1.8.

@ghost ghost removed the review label Mar 22, 2019
@shamal
Copy link

shamal commented Jul 28, 2019

I have the latest amplify cli and I'm still getting this issue. My original API key was expired and I created a new API Key. Updated all references to the API KEY with the new Key in all the files, bgut still amplify push fails telling
API key not found: da2-6ekxe7pt3bgkfbfmbfwhranc5i (Service: AWSAppSync; Status Code: 404; Error Code: NotFoundException; Request ID: 2fe05136-b0e5-11e9-a0fc-59240c6936f3)

@gitzhouxinyu1
Copy link

Any updates? I still got the same error with latest cli

@danieldram
Copy link

I am also still getting this error... I am not sure how to get around it... I've set the epoch to -1 and still get this error.

@ChristopheBougere
Copy link
Contributor

ChristopheBougere commented Oct 13, 2019

@danieldram I just ran into the same issue and for some reason, @mikeparisstuff workaround wasn't working. My AppSync API is configured in AWS_IAM auth mode, but maybe I changed it at some which led to this error.
The solution was to manually re-deploy the failing CloudFormation stack in the console (click on Update) and overriding the APIKeyExpirationEpoch to -1 there. Trying to deploy locally or from Amplify Console didn't work for me (neither than this one).

@danieldram
Copy link

@ChristopheBougere thank you so much for the response, do you know where in the console I can edit the APIKeyExpirationEpoch?

@ChristopheBougere
Copy link
Contributor

To be more specific you don't edit the value but you redeploy the stack with a new value for the parameter.

  • In the console, you probably have 2 failing stacks. One is the root, the other one is the API (a nested stack)
  • Select the nested stack, and click on update
  • Confirm that you want to update the nested stack
  • "Use current template"
  • Then you can update parameters (APIKeyExpirationEpoch)
  • Confirm and deploy
    This kind of manual action is usually not recommended because you could desynchronize with your amplify project. But it worked for me and other solutions didn't work.

@danieldram
Copy link

@ChristopheBougere doesn't seem to work for me.. in the cloudformation console I see all green and when I drill down I find the failing stack, I updated the epoch -1 but still doesn't deploy locally anymore.

@danieldram
Copy link

@ChristopheBougere THANK YOU! how do I donate to your coffee fund! I finally got it working via editing the cloud formation template. You are a genius!

@ChristopheBougere
Copy link
Contributor

Glad to hear that, cheers!

@Rodiot89
Copy link

For some reason I manually deleted the API key of my API and changed authorization to an existing Cognito Pool.
Add one point I got the errors mentioned above.
@ChristopheBougere suggestions of manually updating the stack worked but I also had to set the "CreateApiKey" setting to 0. The expiration epoch alone wasnt doing the trick.

@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working critical-bug Show stopper bug graphql-transformer-v1 Issue related to GraphQL Transformer v1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants