aws-amplify / aws-amplify/amplify-cli

Adding GraphQL API with Cognito User Pool results in hanging error on push

Open
#4,856 3 comments 0 reactions 0 assignees View on GitHub
feature-request p3 platform
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

**Describe the bug**
When I attempt to add an API with Cognito User Pools authentication on a new application, and I push, I receive the following error and the CLI indefinitely hangs:

```console
Template error: instance of Fn::GetAtt references undefined resource authapiaeaa9b10
There was an error pushing the API resource
ValidationError: Template error: instance of Fn::GetAtt references undefined resource authapiaeaa9b10
```

**Amplify CLI Version**
You can use `amplify -v` to check the amplify cli version on your system
4.24.4

**To Reproduce**
Steps to reproduce the behavior or terminal output if applicable

```console
$ amplify init
? Enter a name for the project api
? Enter a name for the environment dev
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building android
Please tell us about your project
? Where is your Res directory: app/src/main/res
Using default provider awscloudformation

$ amplify add api
? Please select from one of the below mentioned services: GraphQL
? Provide API name: api
? Choose the default authorization type for the API Amazon Cognito User Pool
Using service: Cognito, provided by: awscloudformation

The current configured provider is Amazon Cognito.

Do you want to use the default authentication and security configuration? Default configuration
Warning: you will not be able to edit these selections.
How do you want users to be able to sign in? Username
Do you want to configure advanced settings? No, I am done.
Successfully added auth resource
? Do you want to configure advanced settings for the GraphQL API No, I am done.
? Do you have an annotated GraphQL schema? No
? Do you want a guided schema creation? Yes
? What best describes your project: Single object with fields (e.g., “Todo” with ID, name, description)
? Do you want to edit the schema now? No

$ amplify api push
Current Environment: dev

| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | ----------------- |
| Api | api | Create | awscloudformation |
? Are you sure you want to continue? Yes

The following types do not have '@auth' enabled. Consider using @auth with @model
- Todo
Learn more about @auth here: https://docs.amplify.aws/cli/graphql-transformer/directives#auth

GraphQL schema compiled successfully.

Edit your schema at /Users/pignataj/workspace/tmp/api/amplify/backend/api/api/schema.graphql or place .graphql files in a directory at /Users/pignataj/workspace/tmp/api/amplify/backend/api/api/schema
? Do you want to generate code for your newly created GraphQL API No
⠇ Updating resources in the cloud. This may take a few minutes...Error updating cloudformation stack
✖ An error occurred when pushing the resources to the cloud

Template error: instance of Fn::GetAtt references undefined resource authapiaeaa9b10
There was an error pushing the API resource
ValidationError: Template error: instance of Fn::GetAtt references undefined resource authapiaeaa9b10
```

**Expected behavior**
I would expect the API to be successfully created, along with the necessary Cognito resources.

**Screenshots**
n/a

**Desktop (please complete the following information):**
- OS: [e.g. Mac/Windows/Ubuntu] macos
- Node Version. You can use `node -v` to check the node version on your system 14.2.0

**Additional context**
Nada.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with amplify init, amplify add api, and amplify api push using GraphQL and Cognito User Pools. Inspect the generated CloudFormation resources for the undefined authapiaeaa9b10 reference. Done means the API and Cognito resources deploy successfully without the template error or an indefinitely hanging CLI.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, typescript
Domain
api, authentication, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.