Album69
  • About
  • Life
  • Travel
  • Tech
  • Galleries
  • SAP-C02 Notes
  • DOP-C02 Notes
X GitHub LinkedIn YouTube

Amazon API Gateway

Domain 2 (29%). API Gateway is the front door for serverless APIs. Know REST vs HTTP vs WebSocket, throttling, caching, and integration types.

Domain 2: New Solutions
October 9, 2026

Exam relevance: Domain 2 (29%). API Gateway is the front door for serverless APIs. Know REST vs HTTP vs WebSocket, throttling, caching, and integration types.


1. API Types

TypeProtocolUse CaseKey Features
REST APIHTTP/HTTPSFull-featured APIsCaching, usage plans, request validation, API keys
HTTP APIHTTP/HTTPSLow-latency, low-cost APIsSimpler, cheaper, JWT auth, no caching
WebSocket APIWebSocketReal-time bidirectionalChat, gaming, live dashboards

REST API vs HTTP API:

FeatureREST APIHTTP API
CostHigher~70% cheaper
LatencyHigherLower
CachingYesNo
Usage plans / API keysYesNo
Request/response transformationYes (mapping templates)Limited
Private integrationsYesYes
JWT authorizerYesYes (native)
Lambda authorizerYesYes

Use HTTP API for most new serverless APIs. Use REST API when you need caching, usage plans, or advanced request transformation.


2. Integration Types

TypeDescription
Lambda proxyPasses entire request to Lambda; Lambda returns full response
Lambda customAPI Gateway transforms request/response using mapping templates
HTTP proxyPasses request to HTTP endpoint as-is
HTTP customAPI Gateway transforms request/response
AWS serviceDirect integration with AWS services (SQS, DynamoDB, SNS, etc.)
MockReturns a static response without backend

AWS service integration (e.g., API Gateway → SQS directly) removes Lambda from the path — reduces cost and latency for simple operations.


3. Throttling

LevelDefault Limit
Account-level10,000 RPS, burst 5,000
Stage-levelConfigurable per stage
Method-levelConfigurable per method
Usage planPer API key, per day/month/RPS
  • Requests exceeding limits return 429 Too Many Requests
  • Use Usage Plans + API Keys to throttle per customer/client
  • Throttling is applied in order: usage plan → method → stage → account

4. Caching (REST API only)

  • Cache responses at the stage level
  • TTL: 0–3,600 seconds (default 300)
  • Cache capacity: 0.5 GB to 237 GB
  • Cache key: method + path + query strings + headers (configurable)
  • Invalidate cache: Cache-Control: max-age=0 header (requires IAM permission)

5. Authorization

MethodUse Case
IAM authorizationAWS services, internal APIs (SigV4 signing)
Lambda authorizer (token)JWT, OAuth, custom token validation
Lambda authorizer (request)Header, query string, or context-based auth
Cognito User Pool authorizerJWT from Cognito (REST API)
JWT authorizerAny OIDC/OAuth2 provider (HTTP API native)

Lambda authorizer returns an IAM policy that API Gateway caches (TTL configurable). Reduces Lambda invocations for repeated requests.


6. Deployment and Stages

  • Stage: a named reference to a deployment (dev, staging, prod)
  • Stage variables: key-value pairs used in integration URIs (e.g., different Lambda aliases per stage)
  • Canary deployments: route a percentage of traffic to a new deployment before full rollout
Stage: prod
├── Canary: 10% → new deployment
└── 90% → current deployment

7. Private APIs

  • Deploy API Gateway inside a VPC using a VPC Endpoint (Interface Endpoint)
  • Only accessible from within the VPC or connected networks
  • Resource policy controls which VPCs/accounts can access the private API

8. Exam Scenarios

Scenario 1: A company wants to expose a serverless API with per-customer rate limiting and monthly quotas. What is the solution?

Use REST API with Usage Plans and API Keys. Create a usage plan with throttle (RPS) and quota (requests/month) settings. Associate API keys with the usage plan. Each customer uses their API key, and API Gateway enforces their individual limits.

Scenario 2: A company wants to reduce costs for a high-volume internal API that does not need caching or usage plans. What is the recommendation?

Use HTTP API instead of REST API. HTTP API is ~70% cheaper, has lower latency, and supports Lambda and HTTP integrations. For internal APIs with JWT-based auth, HTTP API’s native JWT authorizer is sufficient.

Scenario 3: A company wants API Gateway to write messages directly to SQS without invoking Lambda. What is the integration type?

Use AWS service integration (non-proxy). Configure API Gateway to call the SQS SendMessage API directly using a mapping template to format the request. This removes Lambda from the path, reducing cost and latency.

Scenario 4: A company needs an API accessible only from within their VPC. What is the solution?

Create a Private REST API. Create a VPC Interface Endpoint for API Gateway in the VPC. Attach a resource policy to the API that allows access only from the VPC endpoint. The API is not accessible from the internet.


9. Exam Tips

  • HTTP API = cheaper, faster, simpler — use for most new APIs
  • REST API = needed for caching, usage plans, API keys, request transformation
  • WebSocket API = real-time bidirectional — chat, live updates
  • AWS service integration removes Lambda — use for simple pass-through to SQS, DynamoDB, SNS
  • Lambda authorizer caches the IAM policy — reduces repeated Lambda invocations
  • 429 = throttled; 502 = bad gateway (Lambda error); 504 = timeout
  • API Gateway timeout: 29 seconds maximum — Lambda must respond within 29s


🎯 Architecture Decision Notes

API Gateway vs AppSync — REST vs GraphQL

API GatewayAppSync
API styleREST, HTTP, WebSocketGraphQL
Data sourcesLambda, HTTP, AWS service integrationsDynamoDB, Lambda, RDS, HTTP, OpenSearch — combined in one schema
Real-timeWebSocket APIsGraphQL subscriptions
OfflineNot built-inRequires client-side sync strategy (Amplify DataStore); the endpoint alone does not make clients offline-capable

Choose AppSync when the client needs flexible queries across multiple backends in one request and GraphQL subscriptions fit the real-time need. Choose API Gateway for REST contracts, request/response transformations, and usage-plan/throttling controls. For offline mobile, the decision is the client sync architecture, not just the API service.

10. Official References

  • API Gateway Developer Guide
  • HTTP API vs REST API
  • Usage Plans
  • Private APIs

      What's in this sap-c02

      • 1. API Types
      • 2. Integration Types
      • 3. Throttling
      • 4. Caching (REST API only)
      • 5. Authorization
      • 6. Deployment and Stages
      • 7. Private APIs
      • 8. Exam Scenarios
      • 9. Exam Tips
      • 🎯 Architecture Decision Notes
        • API Gateway vs AppSync — REST vs GraphQL
      • 10. Official References
      © Album69 2026
      X GitHub LinkedIn YouTube