Skip to content

AWS API Gateway

Amazon API Gateway is a fully managed service for creating, publishing, and securing APIs at any scale. It acts as the โ€œfront doorโ€ for backend services โ€” Lambda functions, EC2 instances, or any HTTP endpoint.

In Azure terms: API Gateway โ‰ˆ Azure API Management (APIM) + Azure API Gateway

TypeDescriptionUse Case
REST APIFull-featured, supports all integrations and API Gateway featuresProduction APIs requiring advanced features
HTTP APILightweight, lower latency, cheaper (~71% cheaper than REST API)Simple proxy to Lambda or HTTP backends
WebSocket APIPersistent two-way connection between client and serverReal-time apps (chat, gaming, live dashboards)
ConceptDescription
ResourceA URL path (e.g., /users, /users/{id})
MethodHTTP verb on a resource (GET, POST, PUT, DELETE)
IntegrationBackend target โ€” Lambda, HTTP URL, AWS service, Mock
StageDeployment environment โ€” dev, staging, prod
DeploymentSnapshot of the API configuration deployed to a stage
Usage PlanThrottling and quota settings
API KeyClient credential for usage plan access control
AuthorizerLambda custom authorizer or Cognito for authentication
Mapping TemplateTransform request/response payloads
Client (browser/app)
โ†“ HTTPS request
API Gateway
โ†“ proxy integration
AWS Lambda
โ†“
DynamoDB / RDS / S3
โ†“
API Gateway
โ†“ response
Client
IntegrationDescription
Lambda ProxyPass entire request to Lambda, return Lambdaโ€™s response directly
Lambda CustomTransform request/response with mapping templates
HTTP ProxyForward request to any HTTP endpoint
AWS ServiceDirectly invoke S3, DynamoDB, SQS, SNS etc. (no Lambda needed)
MockReturn a static response without any backend call
MethodDescription
API KeysSimple key-based access (not for authentication โ€” use for quota tracking)
Lambda AuthorizerCustom auth logic (validate JWT, call auth service)
Cognito User PoolsAWS-managed OAuth2/OIDC authentication
IAM AuthorizationSigV4-signed requests from AWS SDKs/services
Resource PoliciesIP-based or VPC-based access restrictions
Mutual TLS (mTLS)Client certificate authentication

API Gateway protects backends with built-in rate limiting:

  • Account level: 10,000 requests/second (soft limit)
  • Stage level: Set custom throttle limits per stage
  • Usage Plans: Throttle and quota per API key

Response when throttled: 429 Too Many Requests

FeatureAWS API GatewayAzure API Management
API typesREST, HTTP, WebSocketREST, SOAP, GraphQL, WebSocket
AuthLambda authorizer, Cognito, IAMOAuth2, JWT, subscriptions keys, Azure AD
ThrottlingPer stage / per usage planPer product / per subscription
Developer portalBasicFull-featured developer portal
Mock responsesYesYes (via policies)
Transform payloadsMapping templatesPolicies (XML-based)
CachingYes (per stage)Yes
Private APIsYes (VPC endpoint)Internal tier
PricingPer-request + data transferPer-unit/hour (multi-tier)

API Gateway supports canary releases โ€” route a percentage of traffic to the new version:

Terminal window
# Create a deployment with canary
aws apigateway create-deployment \
--rest-api-id abc123 \
--stage-name prod \
--canary-settings \
percentTraffic=10,\
deploymentId=xyz789
Terminal window
# List APIs
aws apigateway get-rest-apis
# Create a REST API
aws apigateway create-rest-api --name "my-api"
# Get resources
aws apigateway get-resources --rest-api-id abc123
# Deploy to a stage
aws apigateway create-deployment \
--rest-api-id abc123 \
--stage-name prod
# Get an API's stages
aws apigateway get-stages --rest-api-id abc123