Amplify-cli: UPDATE_FAILED GraphQLAPIKey AWS::AppSync::ApiKey - ApiKeyValidityOutOfBoundsException after adding REST API

Created on 4 Mar 2019  ·  2Comments  ·  Source: aws-amplify/amplify-cli

Describe the bug
For a React Native project using Amplify (Auth, Storage, GraphQL api) I am trying to add a REST api. This api should only be accessible for users that are logged in. After adding the api via de CLI I run the amplify push command. This is when the error shows up.

_Before update_

amplify status
Current Environment: develop

| Category | Resource name       | Operation | Provider plugin   |
| -------- | ------------------- | --------- | ----------------- |
| Auth     | cognito             | No Change | awscloudformation |
| Function | createAuthChallenge | No Change | awscloudformation |
| Function | defineAuthChallenge | No Change | awscloudformation |
| Function | verifyAuthChallenge | No Change | awscloudformation |
| Api      | authenticationApi   | No Change | awscloudformation |
| Api      | datamodel           | No Change | awscloudformation |
| Storage  | storage             | No Change | awscloudformation |

_Adding a new rest api via CLI_

amplify api add                                                                                    ✔  10135  10:07:09
? Please select from one of the below mentioned services REST
? Provide a friendly name for your resource to be used as a label for this category in the project: authenticatedRestApi
? Provide a path (e.g., /items) /registerPush
? Choose a Lambda source Create a new Lambda function
? Provide a friendly name for your resource to be used as a label for this category in the project: registerPush
? Provide the AWS Lambda function name: registerPush
? Choose the function template that you want to use: Serverless express function (Integration with Amazon API Gateway)
? Do you want to edit the local lambda function now? No
Succesfully added the Lambda function locally
? Restrict API access Yes
? Who should have access? Authenticated users only
? What kind of access do you want for Authenticated users read/write
? Do you want to add another path? No
Successfully added resource authenticatedRestApi locally

_Creating the backend resources by running amplify push"

amplify push                                                                                   ✔  10136  10:09:04

Current Environment: develop

| Category | Resource name        | Operation | Provider plugin   |
| -------- | -------------------- | --------- | ----------------- |
| Function | registerPush         | Create    | awscloudformation |
| Api      | authenticatedRestApi | Create    | awscloudformation |
| Auth     | cognito              | No Change | awscloudformation |
| Function | createAuthChallenge  | No Change | awscloudformation |
| Function | defineAuthChallenge  | No Change | awscloudformation |
| Function | verifyAuthChallenge  | No Change | awscloudformation |
| Api      | authenticationApi    | No Change | awscloudformation |
| Api      | datamodel            | No Change | awscloudformation |
| Storage  | storage              | No Change | awscloudformation |
? Are you sure you want to continue? Yes
⠙ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS stopcoachapp-20190225141031 AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:19 GMT+0100 (CET) User Initiated
UPDATE_IN_PROGRESS functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_IN_PROGRESS functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_IN_PROGRESS storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
CREATE_IN_PROGRESS functionregisterPush        AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_IN_PROGRESS functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS authcognito                 AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_COMPLETE    storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_COMPLETE    functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_COMPLETE    functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
UPDATE_COMPLETE    functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:24 GMT+0100 (CET)
CREATE_IN_PROGRESS functionregisterPush        AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:25 GMT+0100 (CET) Resource creation Initiated
⠋ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS stopcoachapp-20190225141031-functionregisterPush-1T81KU99DLVRR AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:25 GMT+0100 (CET) User Initiated
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE    authcognito          AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:25 GMT+0100 (CET)
UPDATE_IN_PROGRESS apiauthenticationApi AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:28 GMT+0100 (CET)
UPDATE_IN_PROGRESS apidatamodel         AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:28 GMT+0100 (CET)
UPDATE_COMPLETE    apiauthenticationApi AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:29 GMT+0100 (CET)
⠹ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS LambdaExecutionRole AWS::IAM::Role Mon Mar 04 2019 10:09:29 GMT+0100 (CET)
⠦ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS stopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:29 GMT+0100 (CET) User Initiated
⠇ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS LambdaExecutionRole AWS::IAM::Role Mon Mar 04 2019 10:09:30 GMT+0100 (CET) Resource creation Initiated
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS GraphQLAPIKey AWS::AppSync::ApiKey        Mon Mar 04 2019 10:09:38 GMT+0100 (CET)
UPDATE_IN_PROGRESS GraphQLSchema AWS::AppSync::GraphQLSchema Mon Mar 04 2019 10:09:38 GMT+0100 (CET)
⠦ Updating resources in the cloud. This may take a few minutes...

UPDATE_FAILED GraphQLAPIKey AWS::AppSync::ApiKey        Mon Mar 04 2019 10:09:40 GMT+0100 (CET) API key must be valid for a minimum of 1 days. (Service: AWSAppSync; Status Code: 400; Error Code: ApiKeyValidityOutOfBoundsException; Request ID: 3d9b4f78-3e5d-11e9-a9da-9f9cc2620761)
UPDATE_FAILED GraphQLSchema AWS::AppSync::GraphQLSchema Mon Mar 04 2019 10:09:41 GMT+0100 (CET) Resource update cancelled
⠴ Updating resources in the cloud. This may take a few minutes...

UPDATE_ROLLBACK_IN_PROGRESS stopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:42 GMT+0100 (CET) The following resource(s) failed to update: [GraphQLAPIKey, GraphQLSchema].
⠋ Updating resources in the cloud. This may take a few minutes...

CREATE_COMPLETE    LambdaExecutionRole AWS::IAM::Role        Mon Mar 04 2019 10:09:47 GMT+0100 (CET)
CREATE_IN_PROGRESS LambdaFunction      AWS::Lambda::Function Mon Mar 04 2019 10:09:51 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS LambdaFunction AWS::Lambda::Function Mon Mar 04 2019 10:09:52 GMT+0100 (CET) Resource creation Initiated
CREATE_COMPLETE    LambdaFunction AWS::Lambda::Function Mon Mar 04 2019 10:09:52 GMT+0100 (CET)
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_FAILED               apidatamodel                AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:51 GMT+0100 (CET) Embedded stack arn:aws:cloudformation:eu-west-1:925757248106:stack/stopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS/472f4540-3c19-11e9-b5d9-021d1d6e9e08 was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [GraphQLAPIKey, GraphQLSchema].
CREATE_FAILED               functionregisterPush        AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:51 GMT+0100 (CET) Resource creation cancelled
UPDATE_ROLLBACK_IN_PROGRESS stopcoachapp-20190225141031 AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:52 GMT+0100 (CET) The following resource(s) failed to create: [functionregisterPush]. The following resource(s) failed to update: [apidatamodel].
⠸ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS lambdaexecutionpolicy AWS::IAM::Policy Mon Mar 04 2019 10:09:54 GMT+0100 (CET)
⠇ Updating resources in the cloud. This may take a few minutes...

CREATE_IN_PROGRESS lambdaexecutionpolicy AWS::IAM::Policy Mon Mar 04 2019 10:09:56 GMT+0100 (CET) Resource creation Initiated
⠼ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE    functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_IN_PROGRESS functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:59 GMT+0100 (CET)
UPDATE_IN_PROGRESS authcognito                 AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:59 GMT+0100 (CET)
UPDATE_IN_PROGRESS functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:59 GMT+0100 (CET)
UPDATE_IN_PROGRESS storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:09:59 GMT+0100 (CET)
UPDATE_IN_PROGRESS functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_COMPLETE    authcognito                 AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_COMPLETE    storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_COMPLETE    functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_COMPLETE    functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:00 GMT+0100 (CET)
UPDATE_IN_PROGRESS apidatamodel                AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:01 GMT+0100 (CET)
⠼ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS apiauthenticationApi AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:04 GMT+0100 (CET)
UPDATE_COMPLETE    apiauthenticationApi AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:05 GMT+0100 (CET)
⠇ Updating resources in the cloud. This may take a few minutes...

CREATE_COMPLETE lambdaexecutionpolicy AWS::IAM::Policy Mon Mar 04 2019 10:10:04 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

CREATE_COMPLETE stopcoachapp-20190225141031-functionregisterPush-1T81KU99DLVRR AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:07 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE    GraphQLAPIKey AWS::AppSync::ApiKey        Mon Mar 04 2019 10:10:29 GMT+0100 (CET)
UPDATE_IN_PROGRESS GraphQLSchema AWS::AppSync::GraphQLSchema Mon Mar 04 2019 10:10:29 GMT+0100 (CET)
⠼ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE GraphQLSchema AWS::AppSync::GraphQLSchema Mon Mar 04 2019 10:10:43 GMT+0100 (CET)
⠋ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE apidatamodel AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:50 GMT+0100 (CET)
⠹ Updating resources in the cloud. This may take a few minutes...

UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS stopcoachapp-20190225141031 AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:51 GMT+0100 (CET)
UPDATE_IN_PROGRESS                           apidatamodel                AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:52 GMT+0100 (CET)
UPDATE_IN_PROGRESS                           apiauthenticationApi        AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:52 GMT+0100 (CET)
DELETE_IN_PROGRESS                           functionregisterPush        AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:52 GMT+0100 (CET)
⠦ Updating resources in the cloud. This may take a few minutes...

UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS stopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:48 GMT+0100 (CET)
⠇ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:53 GMT+0100 (CET)
UPDATE_COMPLETE    apiauthenticationApi        AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:53 GMT+0100 (CET)
UPDATE_COMPLETE    storagestorage              AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:53 GMT+0100 (CET)
UPDATE_IN_PROGRESS functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
UPDATE_IN_PROGRESS functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
UPDATE_IN_PROGRESS functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE functiondefineAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
UPDATE_COMPLETE functionverifyAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
UPDATE_COMPLETE functioncreateAuthChallenge AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)


DELETE_IN_PROGRESS stopcoachapp-20190225141031-functionregisterPush-1T81KU99DLVRR AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:53 GMT+0100 (CET) User Initiated
DELETE_IN_PROGRESS lambdaexecutionpolicy                                          AWS::IAM::Policy           Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
⠇ Updating resources in the cloud. This may take a few minutes...

UPDATE_ROLLBACK_COMPLETE stopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS AWS::CloudFormation::Stack Mon Mar 04 2019 10:10:54 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

DELETE_COMPLETE lambdaexecutionpolicy AWS::IAM::Policy Mon Mar 04 2019 10:10:56 GMT+0100 (CET)
⠸ Updating resources in the cloud. This may take a few minutes...

DELETE_IN_PROGRESS LambdaFunction                                                 AWS::Lambda::Function      Mon Mar 04 2019 10:10:57 GMT+0100 (CET)
DELETE_COMPLETE    LambdaFunction                                                 AWS::Lambda::Function      Mon Mar 04 2019 10:10:57 GMT+0100 (CET)
DELETE_IN_PROGRESS LambdaExecutionRole                                            AWS::IAM::Role             Mon Mar 04 2019 10:10:58 GMT+0100 (CET)
DELETE_COMPLETE    LambdaExecutionRole                                            AWS::IAM::Role             Mon Mar 04 2019 10:10:59 GMT+0100 (CET)
DELETE_COMPLETE    stopcoachapp-20190225141031-functionregisterPush-1T81KU99DLVRR AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:00 GMT+0100 (CET)
⠏ Updating resources in the cloud. This may take a few minutes...

UPDATE_COMPLETE apidatamodel         AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:03 GMT+0100 (CET)
DELETE_COMPLETE functionregisterPush AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:03 GMT+0100 (CET)
⠴ Updating resources in the cloud. This may take a few minutes...

UPDATE_IN_PROGRESS       authcognito                 AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:05 GMT+0100 (CET)
UPDATE_COMPLETE          authcognito                 AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:05 GMT+0100 (CET)
UPDATE_ROLLBACK_COMPLETE stopcoachapp-20190225141031 AWS::CloudFormation::Stack Mon Mar 04 2019 10:11:06 GMT+0100 (CET)
⠼ Updating resources in the cloud. This may take a few minutes...Error updating cloudformation stack
⠼ Updating resources in the cloud. This may take a few minutes...

Following resources failed

Resource Name: cpmecetzijepjoznyviuest2byGraphQLSchema (AWS::AppSync::GraphQLSchema)
Event Type: update
Reason: Resource update cancelled
URL: https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/arn%3Aaws%3Acloudformation%3Aeu-west-1%3A925757248106%3Astack%2Fstopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS%2F472f4540-3c19-11e9-b5d9-021d1d6e9e08/events


Resource Name: arn:aws:appsync:eu-west-1:925757248106:apis/cpmecetzijepjoznyviuest2by/apikeys/da2-mdq2mgdzwrgonlrwk2mbvwbiv4 (AWS::AppSync::ApiKey)
Event Type: update
Reason: API key must be valid for a minimum of 1 days. (Service: AWSAppSync; Status Code: 400; Error Code: ApiKeyValidityOutOfBoundsException; Request ID: 3d9b4f78-3e5d-11e9-a9da-9f9cc2620761)
URL: https://console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks/arn%3Aaws%3Acloudformation%3Aeu-west-1%3A925757248106%3Astack%2Fstopcoachapp-20190225141031-apidatamodel-9WG2MZ8FN4SS%2F472f4540-3c19-11e9-b5d9-021d1d6e9e08/events


✖ An error occurred when pushing the resources to the cloud

Resource is not in the state stackUpdateComplete

I don't understand why the ApiKeyValidityOutOfBoundsException errors shows up. The GraphQL api that I added before is not based on an API Key but on a cognito user pool instead. So what API key is not valid anymore?

Expected behavior
I would expect the rest api to be created without any problems. The errors seems completely unrelated.

Screenshots
screenshot 2019-03-04 at 10 32 55

** Project dependencies

    "aws-amplify": "^1.1.19",
    "aws-amplify-react-native": "^2.1.7",

Amplify cli version 1.1.6

bug documentation graphql-transformer

Most helpful comment

I had similar issue. Setting APIKeyExpirationEpoch to -1 in amplify/backend/api/parameters.json did help.
(source: https://github.com/aws-amplify/amplify-cli/issues/808#issuecomment-460377984)

All 2 comments

I had similar issue. Setting APIKeyExpirationEpoch to -1 in amplify/backend/api/parameters.json did help.
(source: https://github.com/aws-amplify/amplify-cli/issues/808#issuecomment-460377984)

The fix for this has been pushed with the latest CLI version - 1.1.8.

Was this page helpful?
0 / 5 - 0 ratings