Integrations, stages and authorizers
Follow a request through the gateway
An integration defines what receives the request: Lambda proxy passes a structured event and returns an HTTP-shaped response; an HTTP proxy forwards to an HTTP backend; supported AWS service integrations call selected service actions without Lambda. Each choice needs appropriate permissions and a defined request/response contract. Non-proxy REST integrations can transform payloads through mapping templates; HTTP API parameter mappings have different capabilities. Do not copy mapping syntax between products.
Read a version 2.0 event
For HTTP API Lambda proxy payload format 2.0, requestContext.http.method identifies the HTTP method, rawPath contains the path (without a custom domain API mapping prefix), and body is normally a string or null. Check isBase64Encoded before interpreting binary content. This chapter uses only plain JSON text. A response can explicitly specify statusCode, headers and a string body. Example: return {"statusCode":200,"headers":{"content-type":"application/json"},"body":"[]"}. The client receives HTTP 200 and an empty JSON array, not the outer Python dictionary. Format 1.0 uses a different event structure; select the configured version explicitly.
Separate identity, route authorization and ownership
An HTTP API JWT authorizer can validate a token from a trusted issuer using configured audience and optional route scopes. IAM authorization is appropriate for signed AWS requests; a Lambda authorizer can implement custom access decisions. An API key in a REST usage plan identifies usage, not a trustworthy user identity. The backend must still check whether the authenticated principal owns the requested book. Do not trust a user-supplied owner field. In the offline fixture the claims are synthetic and already trusted by assumption; the code never verifies a real JWT. The Lambda resource permission to allow API Gateway invocation is separate from the function execution role.
Deploy and observe deliberately
A deployment captures API configuration; a stage exposes a deployment under an environment name such as test or prod. HTTP API stages can enable automatic deployment; $default is a special stage without a stage path prefix. A custom domain maps a name to a stage; use a valid certificate and verified DNS. Enable stage access logs with request ID, status and latency, without logging tokens or full private bodies. Review changes in test before prod. Practice: map a JWT-protected POST route to a Lambda integration, choose payload 2.0, identify the ownership check and decide how to verify the response. No actual deployment is performed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Integrations, stages and authorizers — knowledge check
Reason about a fictional bookstore API without cloud access.
What does an integration specify?
Which field holds the method in an HTTP API payload 2.0 event?
A valid JWT permits the route, but the book belongs to another customer. What should the backend do?
What is a stage used for?
Which permission enables API Gateway to invoke a Lambda function?