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

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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠