Prompt
What should I use with AWS API Gateway for API security?
Latest observation
Oct 29, 2026
OpenAI APIWeb search: off
For AWS API Gateway, the best security setup depends on who should access the API and how. In practice, you usually combine authentication + authorization + network controls + throttling.
Common options for API Gateway security
1) Amazon Cognito
Best for:
- User-facing apps
- Mobile/web apps
- APIs needing user sign-in
How it works:
- Users authenticate with Cognito
- API Gateway validates JWTs via a Cognito User Pool authorizer
- Good for OAuth2/OpenID Connect workflows
Use when:
- You want user login, sign-up, password reset, MFA, social login, etc.
2) Lambda Authorizer
Best for:
- Custom auth logic
- Third-party tokens
- Legacy auth systems
- Complex authorization rules
How it works:
- API Gateway sends the incoming token/request to a Lambda function
- Lambda decides allow/deny and can return IAM-style policies or claims
Use when:
- Cognito isn’t a fit
- You need custom validation, fine-grained access control, or integration with an external IdP
3) IAM Authorization
Best for:
- Service-to-service calls
- Internal AWS clients
- Trusted workloads inside AWS
How it works:
- Requests are signed with AWS Signature Version 4
- API Gateway checks IAM permissions
Use when:
- Your callers are AWS users, roles, Lambda functions, ECS tasks, EC2, etc.
4) OpenID Connect / JWT authorizers
Best for:
- APIs used by enterprise identity providers
- External IdPs like Auth0, Okta, Azure AD
How it works:
- API Gateway validates JWTs from your identity provider
Use when:
- You already have an external identity platform
Extra protections you should also use
5) AWS WAF
Add WAF in front of API Gateway to protect against:
- SQL injection
- XSS
- Bad bots
- IP reputation threats
- Rate-based abuse
This is a very common and recommended layer.
6) Throttling and quotas
Use API Gateway controls to:
- Limit requests per second
- Set burst limits
- Apply usage plans and API keys if needed
Good for:
- Preventing abuse
- Protecting backend services
- Managing partner/developer access
7) Private APIs + VPC endpoints
Best for internal APIs only:
- Make the API accessible only from your VPC via PrivateLink/VPC endpoint
- Avoid public internet exposure
Use when:
- API is internal to your AWS environment or private network
8) TLS/HTTPS only
Always:
- Require HTTPS
- Use modern TLS
- Disable plain HTTP access
Recommended choices by scenario
Public app with user login
Use:
- Cognito or JWT authorizer
- AWS WAF
- Throttling
- Optional Lambda authorizer for special rules
Internal service-to-service API
Use:
- IAM authorization
- Private API
- WAF if internet-facing
- Throttling
Enterprise API with external IdP
Use:
- JWT authorizer or Lambda authorizer
- WAF
- Throttling
- Optional mTLS if you need strong client identity
Partner API
Use:
- JWT or Lambda authorizer
- Usage plans / API keys
- WAF
- Rate limits
- Possibly mTLS
Best-practice recommendation
If you want a solid default architecture, use:
- JWT-based auth with Cognito or your IdP
- AWS WAF
- API Gateway throttling
- Least-privilege IAM for backend integration
- Private API for internal-only access
If you want, I can recommend the best security setup for your exact use case if you tell me whether your API is:
- public or internal,
- user-facing or service-to-service, and
- using Cognito, an external IdP, or custom auth.