1

I have a react app that uploads a file to S3. When the user press a button to extract text out of the file, the app will call a GET to API Gateway and send the file name as parameter. This will trigger the lambda function to extract the text from the file on the S3. But I am stuck with the API that needs to call the Lambda function.

I followed this tutorial from AWS: https://docs.aws.amazon.com/apigateway/latest/developerguide/integrating-api-with-aws-services-lambda.html#api-as-lambda-proxy-expose-get-method-with-query-strings-to-call-lambda-function

This is what the response is what I get when I test the API call:

Received response. Status: 403, Integration latency: 3 ms
Sun Oct 25 13:29:26 UTC 2020 : Endpoint response headers: {Date=Sun, 25 Oct 2020 13:29:26 GMT, Content-Length=130, Connection=keep-alive, x-amzn-RequestId=d8eab391-05a7-44f2-9721-ce67939a9514}
Sun Oct 25 13:29:26 UTC 2020 : Endpoint response body before transformations: <AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

Sun Oct 25 13:29:26 UTC 2020 : Method response body after transformations: <AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

Sun Oct 25 13:29:26 UTC 2020 : Method response headers: {X-Amzn-Trace-Id=Root=1-5f957db6-4e36be9def67f8157b8467c5, Content-Type=application/json}
Sun Oct 25 13:29:26 UTC 2020 : Successfully completed execution
Sun Oct 25 13:29:26 UTC 2020 : Method completed with status: 200

Every single post that I read about this error said that the problem is that my HTTP method must be a POST, BUT IT IS? Here in the screenshot of my settings:

Screenshot of my API integration request


So my question is, how do I fix this so that my API can call my Lambda function and return the text back to the app?
2
  • What is myLambdaRole? Commented Oct 25, 2020 at 22:50
  • Execution role for the lambda function. It has full lambda and cloudwatch access, as well as allowed to invoke a lambda function Commented Oct 26, 2020 at 7:53

1 Answer 1

2

AWS Service integration type is to ingrate the api gateway with any AWS service. Even though a lambda is a AWS feature, there is a Lambda integration type for this specifically there for integrating lambdas. I think lambda integration type is the suitable one in this case.

You can pass the file name in the GET request as well (for example as a query string parameter).

If you like to use the AWS Service integration type, make sure to add permission for api gateway to invoke the lambda. you need to add this permission in Lambda IAM Role's trust policy.

Sign up to request clarification or add additional context in comments.

8 Comments

is there any reason why you are using AWS Service integration type over Lambda integration type
Hi, yea the reason for using that instead of lambda integration was the fact that AWS did it in the tutorial so I assumed that it would be "more correct"
did you check the cloudwatch logs for lambda, is the request reaching there
Amazing. I changed it to Lambda integration and it works. THANKS Arun!! You must go help AWS to write better tutorials! xD
Dont worry about it. The only thing i cant think of is, the lambda's role should allow the api gateway service to invoke itself using the trust policy. can you post the lambda's IAM role's trust policy
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.