aws-amplify / aws-amplify/amplify-cli
`amplify push function` also pushes GraphQL API, fails if GraphQL has IAM
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### 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:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Contributor guide
Research direction
The command flow is visible in amplify-category-function/index.js and amplify-helpers/push-resources.js in the reported stack trace; start there and reproduce with amplify init -y, amplify add api > GraphQL, then amplify push function. Done means a function-only push detects that no functions exist, exits before pushing the GraphQL API, and prints the expected no-functions message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100