aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.82k stars 821 forks source link

`amplify push function` also pushes GraphQL API, fails if GraphQL has IAM #12348

Open josefaidt opened 1 year ago

josefaidt commented 1 year ago

How did you install the Amplify CLI?

pnpm

If applicable, what version of Node.js are you using?

18

Amplify CLI Version

11.0.3

What operating system are you using?

mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

n/a

Describe the bug

amplify push function should fail fast if no functions are available in the project

➜  amplify push function
⠴ Building resource api/a12289✅ GraphQL schema compiled successfully.

Edit your schema at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema.graphql or place .graphql files in a directory at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema

    Current Environment: dev

┌──────────┬───────────────┬───────────┬─────────────────┐
│ Category │ Resource name │ Operation │ Provider plugin │
└──────────┴───────────────┴───────────┴─────────────────┘
✔ Are you sure you want to continue? (Y/n) · yes
✅ GraphQL schema compiled successfully.

Edit your schema at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema.graphql or place .graphql files in a directory at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema
⠦ Building resource api/a12289✅ GraphQL schema compiled successfully.

Edit your schema at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema.graphql or place .graphql files in a directory at /Users/josef/Documents/projects/aws-amplify/reproductions/a12289two/amplify/backend/api/a12289/schema

Deployment failed.
Deploying root stack a12289 [ ========-------------------------------- ] 1/5
        amplify-a12289-dev-155308      AWS::CloudFormation::Stack     UPDATE_ROLLBA
        autha12289c4c09eca             AWS::CloudFormation::Stack     UPDATE_COMPLE
        apia12289                      AWS::CloudFormation::Stack     UPDATE_FAILED

🛑 The following resources failed to deploy:
Resource Name: apia12289 (AWS::CloudFormation::Stack)
Event Type: update
Reason: Parameters: [unauthRoleName, authRoleName] must have values
URL: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/arn%3Aaws%3Acloudformation%3Aus-east-1%3A814763596509%3Astack%2Famplify-a12289-dev-155308%2F51d30730-c904-11ed-9dd2-12f540fc6bd9/events

PushResourcesFault: Resource is not in the state stackUpdateComplete
    at AmplifyToolkit.pushResources (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:143:23)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-function/lib/index.js:277:5)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:135:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:33:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:117:5)
An error occurred when pushing the function resource

Expected behavior

➜  amplify push function
No functions are available in this Amplify project

Reproduction steps

  1. amplify init -y
  2. amplify add api > GraphQL
  3. amplify push function
  4. observe CLI does not fail, prints an empty status page, then proceeds with pushing the API

Project Identifier

No response

Log output

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

josefaidt commented 1 year ago

related https://github.com/aws-amplify/amplify-cli/issues/9484

ykethan commented 1 year ago

was able to reproduce the issue from the steps provided, marking as bug.

josefaidt commented 1 year ago

also related https://github.com/aws-amplify/amplify-cli/issues/12324 note for fix: GraphQL API should not be pushed when attempting to push a specific category that is not api

espenbye commented 1 year ago

Experiencing the same issue with CLI 11.0.5. Default authentication is set to Cognito User Pools, with IAM as an additional provider.

espenbye commented 1 year ago

Any ETA on this to be included in a release? :)