aws-amplify / amplify-cli

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

AWS_Lambda auth type not supported in headless [amplify add api --headless] #13728

Open aroradev-dms opened 4 months ago

aroradev-dms commented 4 months ago

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

{
    "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"
        }
    }
} 
  1. 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:

vishal-dms commented 4 months ago

PR #13729 is merged and hence this issue can be closed.