Skip to Content
Asterrr's Handbook
2 · New solutions

Amazon API Gateway

REST, HTTP and WebSocket APIs compared, integrations, authorizers, throttling, stages and canaries, caching, private APIs and custom domains.

Exam tasks: 2.3 (secure APIs), 2.5 (performance), 4.3 and 4.4 (modernize with APIs), 3.2

The decision: which API type gives the features you need at the lowest cost, how are callers authenticated, and how do you protect the backend from too much traffic?

API Gateway is a managed front door for APIs. It authenticates, throttles, transforms and routes calls to Lambda, HTTP backends, AWS services and private resources.

AWS CloudVPCHTTPSauthorizeVPC linkNLB through VPClinkPrivate serviceAWS WAFAPI GatewayAuthorizerLambdaAPI clients
Clients reach the API through WAF. API Gateway authorizes the call, then integrates with Lambda, or with a private service through a VPC link.
29 s
Default maximum integration timeout for REST APIs
10 MB
Maximum payload size
10,000 / 5,000
Default account-level steady rate and burst per Region, in requests per second
300 s
Default cache TTL. Maximum 3,600
us-east-1
Region of the ACM certificate for an edge-optimized custom domain

REST, HTTP and WebSocket

REST APIHTTP APIWebSocket API
Cost and latencyHigherLower and fasterPer message and connection minute
AuthorizersIAM, Cognito, LambdaIAM, JWT, LambdaIAM, Lambda
API keys and usage plansYesNoNo
CachingYesNoNo
WAFYesNoNo
Request validation and transformationYesLimitedRoute selection
Canary releasesYesNoNo
Private APIYesNoNo
Endpoint typesEdge-optimized, regional, privateRegionalRegional

Exam signal

Need WAF, API keys with usage plans, caching or private endpoints: REST API. Need the lowest cost with JWT authorization for a simple proxy: HTTP API. Need two-way push to clients: WebSocket API.

Integrations

  • Lambda proxy passes the request to the function and returns what it returns. It is the common choice.
  • HTTP proxy forwards to a public HTTP endpoint. AWS service integrations call services such as SQS, Step Functions or DynamoDB directly, with no Lambda in between. Mock returns a fixed response.
  • VPC link connects to private resources. REST APIs reach a Network Load Balancer, and HTTP APIs can reach an ALB, an NLB or Cloud Map services.
  • REST APIs wait up to 29 seconds by default, so long work should be asynchronous: accept the request, queue it, and return a status endpoint.

Authorizers

TypeUse it when
IAM (SigV4)Callers already hold AWS credentials, such as other services or federated users
Cognito user poolYour users sign in with Cognito and send an access or ID token
Lambda authorizerYou need custom logic on a token or on headers, query strings and stage variables. Results are cached, default 300 seconds
JWT authorizer (HTTP API)Any OIDC provider issues the tokens
Resource policyAllow or deny by source IP, VPC endpoint or account

API keys are not authentication

An API key identifies a client for throttling and metering through a usage plan. It is not an authorization mechanism. A question that wants to restrict who can call the API needs IAM, Cognito or a Lambda authorizer.

Throttling, stages and releases

  • Limits apply at the account, the stage or method and the usage plan. Calls beyond the limit get a 429, so clients should retry with backoff.
  • Stages such as dev and prod have their own settings, stage variables and logging. A change reaches a stage only after you create a deployment.
  • A canary release on a REST stage sends a percentage of traffic to the new deployment before you promote it.
  • Logging: access logs to CloudWatch Logs or Data Firehose, execution logs for debugging, and X-Ray for traces.

Caching

  • Enabled per stage, with per-method overrides. Only REST APIs have it; HTTP APIs don't.
  • Choose which request parameters (headers, query strings, path) form the cache key.
  • Clients can send Cache-Control: max-age=0 to bypass the cache. Require authorization for this, or anyone can force misses.
  • For a public, cacheable API, CloudFront in front of API Gateway gives edge caching too.

Private APIs and custom domains

  • A private API is reachable only through an interface VPC endpoint for execute-api, and a resource policy must allow that endpoint.
  • A custom domain name needs an ACM certificate, in us-east-1 for edge-optimized APIs and in the API's Region for regional ones, and a Route 53 alias. Mutual TLS is available on custom domains.

Scenarios

Scenario
A company exposes a REST API to partners. One partner sends far more requests than agreed and slows the backend for everyone. The company wants to cap each partner separately and bill by usage. Which feature fits?
Scenario
A team needs an internal API that must never be reachable from the internet. It should be called only from workloads inside two VPCs, with a WAF-style IP allow list at the API layer. Which design fits?
Scenario
A mobile backend runs on Lambda behind API Gateway. Reads for a product catalog repeat constantly and the data changes once a day. The team wants to cut Lambda invocations and latency without changing code. What should they do?

Further reading

On this page