DVA-C02 Question 345
Single answerYou are developing a serverless application on AWS Lambda that interacts with an Amazon API Gateway endpoint. During testing, the Lambda function invokes the API Gateway endpoint, but it receives a 403 Forbidden error. What is the MOST likely cause of this error?
- A
The API Gateway endpoint is throttling the requests from the Lambda function.
- B
The Lambda function's IAM role does not have the required permissions to invoke the API Gateway endpoint.
- C
The request payload sent from the Lambda function is malformed.
- D
The Lambda function is attempting to access a resource that is restricted by an API Gateway resource policy.
Show answer and explanation
Correct answer: D
Explanation
A 403 Forbidden error indicates that the client (in this case, the Lambda function) does not have permission to access the requested resource. This is often due to restrictions in the API Gateway resource policy, such as IP address whitelisting, VPC restrictions, or specific IAM role trust relationships. Understanding common HTTP error codes and their causes is essential for diagnosing and resolving issues in AWS applications.
- A. Incorrect.
403 Forbidden errors are not caused by throttling; throttling would result in a 429 Too Many Requests error.
- B. Incorrect.
API Gateway endpoints do not require IAM role permissions for the client invoking it unless explicitly configured with IAM authorization. A 403 error is more likely related to resource access.
- C. Incorrect.
While a malformed request payload could cause issues, it would typically result in a 400 Bad Request error, not a 403 Forbidden error.
- D. Correct.
A 403 Forbidden error is most commonly caused when the API Gateway resource policy explicitly denies access to the resource or restricts it to specific client IPs, VPCs, or trusted roles.