aws-amplify / aws-amplify/amplify-cli
AWS_Lambda auth type not supported in headless [amplify add api --headless]
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### How did you install the Amplify CLI?
_No response_
### If applicable, what version of Node.js are you using?
_No response_
### Amplify CLI Version
12.10.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.
No
### Describe the bug
Unable to add/modify GraphQL API with Lambda authorisation using headless.
### Expected behavior
We should be able to add/modify GraphQL API with Lambda authorisation using headless.
### Reproduction steps
1. amplify init
2. amplify add function (Give function name as "hello")
3. Create a JSON which will have configuration for the GraphQL API. You may refer the below example
myAddApiRequest.json
```json
{
"version": 1,
"serviceConfiguration": {
"serviceName": "AppSync",
"apiName": "newHeadlessApi",
"transformSchema": "type Salary @model @auth(rules: [{ allow: custom }]) {\r\n id: ID!\r\n wage: Int\r\n currency: String\r\n}",
"defaultAuthType": {
"mode": "AWS_LAMBDA",
"lambdaFunction": "hello"
}
}
}
```
4. Perform command `cat myAddApiRequest.json | jq -c | amplify add api --headless`
===Error
```
{"errorName":"UnknownFault","errorMessage":"Data did not validate against the supplied schema. Underlying errors were [{\"keyword\":\"enum\",\"dataPath\":\".serviceConfiguration.defaultAuthType.mode\",\"schemaPath\":\"#/definitions/AppSyncAPIKeyAuthType/properties/mode/enum\",\"params\":{\"allowedValues\":[\"API_KEY\"]},\"message\":\"should be equal to one of the allowed values\"},{\"keyword\":\"enum\",\"dataPath\":\".serviceConfiguration.defaultAuthType.mode\",\"schemaPath\":\"#/definitions/AppSyncAWSIAMAuthType/properties/mode/enum\",\"params\":{\"allowedValues\":[\"AWS_IAM\"]},\"message\":\"should be equal to one of the allowed values\"},{\"keyword\":\"enum\",\"dataPath\":\".serviceConfiguration.defaultAuthType.mode\",\"schemaPath\":\"#/definitions/AppSyncCognitoUserPoolsAuthType/properties/mode/enum\",\"params\":{\"allowedValues\":[\"AMAZON_COGNITO_USER_POOLS\"]},\"message\":\"should be equal to one of the allowed values\"},{\"keyword\":\"enum\",\"dataPath\":\".serviceConfiguration.defaultAuthType.mode\",\"schemaPath\":\"#/definitions/AppSyncOpenIDConnectAuthType/properties/mode/enum\",\"params\":{\"allowedValues\":[\"OPENID_CONNECT\"]},\"message\":\"should be equal to one of the allowed values\"},{\"keyword\":\"anyOf\",\"dataPath\":\".serviceConfiguration.defaultAuthType\",\"schemaPath\":\"#/properties/defaultAuthType/anyOf\",\"params\":{},\"message\":\"should match some schema in anyOf\"}]","resolution":"Please report this issue at https://github.com/aws-amplify/amplify-cli/issues and include the project identifier from: 'amplify diagnose --send-report'","link":"https://docs.amplify.aws/cli/project/troubleshooting/"}
```
### 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
Assessment
This issue has not been assessed yet.