amplify-cli: Converting from Expired API Key to Cognito causes Cloudformation to fail.
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:
- Create a new project and use API Key as the auth type
- Expire the API key
- Convert existing project to Cognito using
amplify api update - Execute
amplify push - This would cause Cloudformation to fail.
Expected behavior Auth type to switch to Cognito instead of API key
Screenshots

Additional context Using Amplify for Javascript with React. Using Amplify version 1.1.6
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 15 (6 by maintainers)
Commits related to this issue
- fix: conditonally create AppSync API Key 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 ... — committed to yuth/amplify-cli by yuth 5 years ago
- fix: conditonally create AppSync API Key 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 ... — committed to mikeparisstuff/amplify-cli by yuth 5 years ago
- Merge pull request #1029 from mikeparisstuff/issue954 Fixing issue #954 — committed to aws-amplify/amplify-cli by mikeparisstuff 5 years ago
To be more specific you don’t edit the value but you redeploy the stack with a new value for the parameter.
APIKeyExpirationEpoch)Any updates? I still got the same error with latest cli
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)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.
@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!
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.
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…