Lambda Function GraphQL Authentication issues

0

I've created a new function using the latest version of the CLI and granted access to the API resources as stated in the docs.

The generated function resources seem to miss Authorization to access AppSync schema, since any type of access attempt ends up in the following response:

{
   "data":{
      "getUsers":null
   },
   "errors":[
      {
         "path":[
            "getUsers"
         ],
         "data":null,
         "errorType":"Unauthorized",
         "errorInfo":null,
         "locations":[
            {
               "line":2,
               "column":9,
               "sourceName":null
            }
         ],
         "message":"Not Authorized to access getUsers on type Query"
      }
   ]
}

I've double-checked and the CLI recognizes/shows that the generated function has the required Resource access permissions. Existing functions created following the same exact steps (with previous CLI versions) are working correctly.

Expected behavior The function should have access to the resources we specified during the creation process.

Reproduction steps

  1. amplify add function
  2. follow all required steps & grant access to the AppSync API
  3. try to retrieve data by accessing Appsync

Here is the link to the github repo issue created with further details: https://github.com/aws-amplify/amplify-cli/issues/10141

已提问 2 年前726 查看次数
1 回答
0

Hi, from my experience, we had API_LIVETRACE_GRAPHQLAPIENDPOINTOUTPUT, API_LIVETRACE_GRAPHQLAPIIDOUTPUT, API_LIVETRACE_GRAPHQLAPIKEYOUTPUT in Lambda environment variables.

Then I need attach {'x-api-key': os.env[['API_LIVETRACE_GRAPHQLAPIKEYOUTPUT']]} to the headers when send request to os.env[['API_LIVETRACE_GRAPHQLAPIENDPOINTOUTPUT]].

已回答 2 年前
  • Thanks for your input Hoan, I'm already adding that header and signing the request as described in the documentation. The issue is that even though the IAM roles are assigned correctly, AppSync seems to deny the acces.

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则