5.3 Amazon API Gateway

Key Takeaways

  • API Gateway is a fully managed service for creating, publishing, and securing REST, HTTP, and WebSocket APIs at any scale.
  • REST APIs offer full feature set (caching, request validation, WAF integration, usage plans); HTTP APIs are simpler, faster, and up to 71% cheaper.
  • API Gateway integrates with Lambda (serverless APIs), EC2/ALB/NLB, and any HTTP endpoint as backend targets.
  • Usage plans and API keys enable rate limiting, throttling, and monetization of APIs.
  • API Gateway supports request/response transformation, CORS configuration, custom authorizers (Lambda, Cognito), and canary deployments.
Last updated: March 2026

Amazon API Gateway

Quick Answer: API Gateway creates and manages APIs. REST APIs offer full features (caching, WAF, usage plans). HTTP APIs are simpler and up to 71% cheaper. Both integrate with Lambda for serverless APIs. Use API Gateway + Lambda for serverless API architecture.

API Types

TypeProtocolFeaturesCostBest For
REST APIHTTPCaching, WAF, usage plans, API keys, request validation, canary$3.50/million requestsFull-featured APIs, monetized APIs
HTTP APIHTTPSimple routing, JWT authorizers, CORS$1.00/million requestsSimple APIs, Lambda proxy, cost-sensitive
WebSocket APIWebSocketBidirectional real-time communication$1.00/million messagesChat, notifications, streaming

Key Features

Authentication and Authorization

MethodDescription
IAMIAM policies control access (great for AWS-to-AWS)
CognitoUser pools for token-based auth
Lambda AuthorizerCustom auth logic (validate tokens, check databases)
API KeysIdentify callers (not for authentication — for tracking/throttling)

Caching (REST API only)

FeatureDetail
TTL0-3600 seconds (default 300 seconds)
Size0.5 GB to 237 GB
Per-stageEach deployment stage has its own cache
InvalidationPer-key invalidation or flush entire cache
Cost$0.020/hour (0.5 GB) to $3.800/hour (237 GB)

Throttling

SettingDefault
Account-level10,000 requests/second per Region
Stage-levelConfigurable per stage
Method-levelConfigurable per method
Usage plansPer-client throttling and quota

Integration Types

TypeDescriptionUse Case
Lambda ProxyPasses full request to Lambda; Lambda returns full responseMost common serverless pattern
Lambda CustomAPI Gateway transforms request/responseComplex request/response mapping
HTTP ProxyPasses request to HTTP endpointBackend on EC2, ALB, external service
AWS ServiceDirect integration with AWS services (S3, SQS, Step Functions)No Lambda needed for simple integrations
MockReturns a response without calling any backendTesting, static responses

On the Exam: "Create a serverless REST API with the least operational overhead" → API Gateway + Lambda. "Throttle API requests per client" → API Gateway usage plans with API keys.

Test Your Knowledge

A company wants to create a serverless REST API that triggers Lambda functions and caches responses for 5 minutes. Which API Gateway type should they use?

A
B
C
D
Test Your Knowledge

Which API Gateway integration type allows direct integration with AWS services like SQS without using Lambda?

A
B
C
D