Question #814
A developer is designing an Amazon API Gateway API to simulate responses for a mobile application team before the backend AWS Lambda service is fully developed. The mobile team requires immediate access to predefined error messages with specific HTTP status codes to proceed with integration. The developer must configure the API to return these responses without relying on the incomplete backend. A method for an API resource is being created.
Which solution meets these requirements?
Set the integration type to AWS_PROXY. Create placeholder Lambda functions that return static error messages and status codes.
Set the integration type to MOCK. Configure the method's integration request and integration response to map predefined error messages to corresponding HTTP status codes.
Set the integration type to HTTP_PROXY. Direct API Gateway to forward requests to a temporary external service that returns mock responses.
Set the integration type to MOCK. Define HTTP status codes using the method response and map JSON error messages using the method request.
Explanation
Answer B is correct because:
1. MOCK Integration: This integration type allows API Gateway to return predefined responses without invoking any backend service (like Lambda), which aligns with the requirement to avoid relying on the incomplete backend.
2. Integration Request/Response Mapping: By configuring these mappings, the developer can define static error messages and map them to specific HTTP status codes (e.g., 400, 500), ensuring the mobile team receives the required test responses.
Why other options are incorrect:
- A: AWSPROXY requires actual Lambda functions, which contradicts the requirement to avoid backend dependencies.
- C: HTTPPROXY forwards requests to an external service, which introduces unnecessary complexity and external dependencies.
- D: Method request mappings handle incoming requests, not responses. Status codes and error messages are configured via integration responses, not method requests.
Key Points:
- Use MOCK integration for static responses without backend services.
- Integration responses map error messages to HTTP status codes.
- Avoid backend dependencies (Lambda/HTTP) when mocking responses.
Answer
The correct answer is: B