Join our Newsletter — 33% off our NHI Course
Home› Guides› Amazon API Gateway Security Guide: Authorisers, Resource Policies,…
Guide Cloud Security

Amazon API Gateway Security Guide: Authorisers, Resource Policies, Private APIs and Throttling

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 18 November 2026 17 min read
On this page

Amazon API Gateway is secure when every route has a real authoriser, every API has a resource policy that says who may call it, and API keys are treated as metering tokens rather than credentials. This guide covers the AWS-specific controls: IAM authorisation, Lambda authorisers, Amazon Cognito and JWT authorisers, resource policies, private APIs reached through interface VPC endpoints, usage plans and throttling, and the logging that proves the controls work. For the vendor-neutral picture of what any gateway should enforce, read our API Gateway Security Guide first; this page does not repeat it.

Most API Gateway deployments are machine-to-machine. The callers are services, partner integrations, mobile back ends, CI jobs and, increasingly, AI agents. Each of those callers is a non-human identity (NHI) holding something: an IAM role session, a client credential that mints a JWT, a bearer token checked by a Lambda function, or an API key. The security of the API is the security of those identities and of the policies that decide what they may invoke.

This is an independent guide from NHI Mgmt Group, based on Amazon Web Services' public documentation as of November 2026. It is not sponsored or reviewed by Amazon Web Services. Product features change, so confirm settings against Amazon Web Services' current documentation.

Key takeaways

  • Pick one authoriser per route on purpose: IAM for AWS workloads, a JWT or Cognito authoriser for OAuth clients, and a Lambda authoriser only when you need custom logic.
  • AWS says plainly that API keys must not be used for authentication or authorisation. A key valid for one API in a usage plan can reach every API in that plan.
  • Usage plan throttling and quotas are best effort, not hard limits. Use AWS WAF and AWS Budgets for protection and cost control.
  • Resource policies are the second gate. Use them to pin private APIs to specific VPC endpoints and to restrict public APIs by source.
  • Lambda authoriser caching is a frequent source of privilege bleed: a cached policy must be valid for every resource and method it will be reused on.
  • JWT authorisers on HTTP APIs validate issuer, audience, expiry and scopes. Require scopes so ID tokens are not accepted as access tokens.
  • Turn on execution or access logging, CloudTrail, AWS Config and Security Hub CSPM controls, and alert on authoriser failures and policy changes.

How access control works in Amazon API Gateway

AWS groups API Gateway access control into three layers. The first is authentication and authorisation: resource policies, IAM roles and policies, IAM tags, endpoint policies for interface VPC endpoints, Lambda authorisers and Amazon Cognito user pools. The second is other request controls: CORS, client-side SSL certificates that let your back end verify requests came from API Gateway, and AWS WAF. The third is tracking and limiting: usage plans and API keys.

Two different sets of identities matter. The first set calls the API: workloads, partners and agents that invoke execute-api. The second set manages the API: pipelines and engineers who can create stages, change authorisers, attach resource policies and deploy. The second set is often more dangerous. A deployment role that can call apigateway:PATCH on a stage or swap an authoriser can remove every control on this page in one change.

REST, HTTP and WebSocket APIs

API Gateway offers REST APIs, HTTP APIs and WebSocket APIs, and the authoriser options are not identical. Lambda authorisers in the TOKEN and REQUEST forms, Cognito user pool authorisers, resource policies, usage plans and API keys described here are REST API features. JWT authorisers are an HTTP API feature. The AWS REST versus HTTP API comparison also lists resource policies and AWS WAF as REST API only, so the WAF advice in this guide applies to REST APIs. Check which API type you run before you copy a control from one to the other, and record the type in your API inventory so reviewers know which settings apply.

The evaluation order that matters

For a REST API, think of a request as passing two gates. The authoriser decides whether the caller is who they claim and what the caller may do. The resource policy decides whether calls from that principal, network or endpoint are accepted at all. An explicit deny in either place wins. Design both, because an authoriser that is misconfigured to allow everything is stopped by a tight resource policy, and a broad resource policy is backed up by a strict authoriser.

Choosing an authoriser for machine callers

Every route should have an authoriser that matches the caller type. Routes with an authorisation type of NONE should be rare, documented and reviewed.

CallerAuthoriser to considerCredential the caller holds
AWS workload in your organisation (Lambda, ECS task, EC2 role)IAM authorisation (AWS_IAM)Short-lived role session, SigV4-signed requests
Partner or SaaS integration using OAuth client credentialsJWT authoriser (HTTP API) or Cognito user pool authoriser (REST API)Access token from an identity provider
Caller with a custom token format or multi-factor request contextLambda authoriser, REQUEST typeWhatever your function validates
Metered public clientOne of the above, plus a usage plan API key for metering onlyToken plus API key

IAM authorisation

IAM authorisation is the strongest default for callers that already run in AWS. The caller signs each request with a role session, so there is no long-lived API secret to store or leak. AWS describes IAM roles and policies as controlling both who can create and manage your APIs, as well as who can invoke them. Scope the execute-api:Invoke permission to specific stages, methods and paths rather than execute-api:/*. If a caller still uses IAM user access keys to sign requests, move it to a role; our AWS Access Keys Security Guide covers that migration.

Cognito and JWT authorisers

For OAuth clients, let the identity provider issue tokens and let API Gateway validate them. A REST API can use a Cognito user pool authoriser; an HTTP API can use a JWT authoriser that accepts tokens from any compliant issuer, including Cognito. Machine clients normally use the client credentials grant, so the client secret held by the caller is the NHI to protect, rotate and inventory. See our Amazon Cognito Security Guide for app client settings.

JWT authorisers on HTTP APIs

A JWT authoriser hands token validation to API Gateway. AWS documents the checks it performs: the token header kid must match a key in the issuer's jwks_uri, the signature is checked with that key, iss must match the configured issuer, aud (or client_id when aud is absent) must match a configured audience, exp must be in the future and nbf and iat in the past. If scopes are configured for a route, the token must include at least one of the route's scopes. If any step fails, API Gateway denies the request.

Settings that matter

  • Require authorisation scopes on every route. AWS notes there is no standard way to tell a JWT access token from an OpenID Connect ID token, and recommends configuring routes to require scopes unless you need ID tokens for API authorisation. Without scopes, any valid token from the issuer for that audience is accepted.
  • Keep the audience list short. Each audience entry is a client that may call the API. A shared audience across many APIs means a token minted for one is accepted by all.
  • Plan key rotation with a grace period. AWS states that API Gateway caches the issuer's public key for up to two hours on a best-effort basis and advises a grace period during which both old and new keys are valid. Revoking a signing key at the identity provider therefore does not take effect at the gateway instantly.
  • Know the algorithm constraint. As of November 2026 the documentation states that only RSA-based algorithms are supported for signature checks, so configure your issuer to sign API tokens with RSA.
  • Check identity source. The identity source can be a header such as Authorization or a query string parameter. Prefer the header: tokens in query strings end up in access logs, browser history and proxy logs.

After validation, API Gateway passes the token claims to the integration, so a Lambda back end can read them from the request context. Treat those claims as authoritative only for routes that actually have the authoriser attached. The general JWT hygiene in RFC 8725 JSON Web Token Best Current Practices still applies to how the issuer mints tokens.

Lambda authorisers without privilege bleed

A Lambda authoriser is your own code in the request path. It receives identity information, decides, and returns an IAM policy plus a principal identifier; AWS states that if the Lambda function does not return that information, the call fails. It can also return a context object of string, number or boolean values that is passed to the back end.

TOKEN versus REQUEST

A TOKEN authoriser receives a single bearer token from a named header. A REQUEST authoriser receives a combination of headers, query string parameters, stage variables and $context variables. AWS recommends the REQUEST type because it can base decisions on multiple identity sources, such as $context.path and $context.httpMethod. For TOKEN authorisers you can set a regular expression so API Gateway rejects malformed tokens before invoking your function, which cuts cost and noise from junk traffic.

Caching is where policies leak

When authorisation caching is on, API Gateway caches the returned policy and does not call the function again for matching requests. AWS warns: ensure that your policy is applicable to all resources and methods across your API. The classic failure is an authoriser that returns an Allow for only the method being called. The first request to GET /orders caches an allow; the next request with the same token to DELETE /orders reuses the cached decision or is denied unexpectedly, depending on how the policy was written. Either outcome is a bug.

Two safe patterns exist. Return a policy that lists every resource and method the principal may reach, so the cached document is correct everywhere. Or use a REQUEST authoriser with the path and method in the identity sources, so they become part of the cache key. For TOKEN authorisers with caching on, the token header alone is the cache key. For REQUEST authorisers with caching on, a missing or empty identity source results in a 401 without calling the function, which is a useful fail-closed property.

Treat the authoriser as a privileged NHI

  • Give the authoriser function's execution role only what it needs to validate tokens, such as reading a signing key from AWS Secrets Manager, and nothing that touches data.
  • Fail closed. Any exception, timeout or unexpected token format should produce a deny.
  • Never put secrets, raw tokens or personal data in the returned context object; it flows to back ends and often into logs.
  • Version and review authoriser code like any other access control code, with tests for deny paths.

Resource policies for public and cross-account APIs

A resource policy is a JSON policy attached to a REST API that allows or denies execute-api:Invoke by principal, source IP, VPC or VPC endpoint. AWS publishes examples that show the common patterns.

  • Cross-account access. Grant named roles in a partner account execute-api:Invoke on specific methods and paths, for example only GET /pets on one stage. Name roles, not whole accounts, and pair the policy with IAM authorisation on those methods.
  • Source IP restriction. A public API can deny calls from or allow calls only from defined CIDR ranges with aws:SourceIp. AWS notes that policies not updated for IPv6 may affect clients using the dualstack endpoint, so review IP rules when you enable dualstack.
  • Allow-then-deny structure. The published examples allow * and then add an explicit Deny that fires when a condition is not met. Explicit denies are easier to audit than a long list of allows.

Keep resource policies in infrastructure as code, and remember that, per the AWS resource policy documentation, a policy change on a REST API needs a redeployment to take effect. An approved policy that was never deployed is a common audit finding.

Private APIs and VPC endpoint controls

A private REST API is reachable only through an interface VPC endpoint for execute-api. That removes internet exposure, but it does not by itself limit which VPCs or accounts can reach the API. Two policies do that work.

The API's resource policy

AWS's private API examples restrict calls to a named VPC with aws:SourceVpc or to a named VPC endpoint with aws:SourceVpce, using a Deny with StringNotEquals. Pin to specific endpoint IDs wherever you can. For IP rules on private APIs, use aws:VpcSourceIp: AWS explains that the VPC endpoint for execute-api re-writes the original source IP address, so aws:SourceIp will not match the original caller.

The VPC endpoint policy

Endpoint policies for interface VPC endpoints are IAM resource policies attached to the endpoint itself. AWS describes them as a way to improve the security of your private APIs. Use the endpoint policy to restrict which APIs workloads in that VPC can call through the endpoint, so a compromised workload cannot use a shared endpoint to reach unrelated private APIs. The endpoint policy and the API resource policy together give a two-sided allow list: this endpoint may reach these APIs, and this API accepts only these endpoints.

For wider network design, including endpoint placement and security groups, see our Amazon VPC Security Guide.

Usage plans, API keys and throttling

A usage plan specifies who can access one or more deployed stages and methods, and can set throttling and quota targets per API key. This is a metering feature, and AWS is explicit about its limits.

API keys are not credentials

AWS states: Don't use API keys for authentication or authorization to control access to your APIs. If several APIs sit in one usage plan, a user with a valid key for one API can access all APIs in that plan. Use IAM, a Lambda authoriser or a Cognito user pool for access control instead. AWS also advises using keys that API Gateway generates and keeping confidential information out of keys, because clients typically send them in headers that can be logged.

Even so, API keys are secrets in practice. They identify a customer, attackers use them to consume quota under someone else's name, and they leak in mobile apps and front-end code. Inventory them, assign an owner and expiry review, and delete keys for retired customers. Our guide How to audit API gateway keys and usage plans gives a step-by-step audit.

Throttling is best effort

Throttling limits set the target rate at which throttling starts, at API or method level. Quota limits set the target maximum requests per key per interval. AWS warns that usage plan throttling and quotas are not hard limits, and are applied on a best-effort basis, and advises against relying on them to control costs or block access. Use AWS WAF rate-based rules to manage request floods and AWS Budgets to watch spend. Treat usage plans as fair-use accounting, not as a security boundary.

Another detail: if you publish a developer portal, AWS notes that all APIs in a usage plan can be subscribed to by customers even if you have not made them visible. Group APIs into usage plans by audience, not by convenience.

Logging, monitoring and posture checks

AWS lists six security best practices for API Gateway: least-privilege IAM for creating and changing APIs, request logging to CloudWatch Logs or Amazon Data Firehose, CloudWatch alarms, AWS CloudTrail, AWS Config and AWS Security Hub CSPM. AWS adds that these are general guidelines and don't represent a complete security solution.

What to log and alert on

  • Access logs with the caller identity, authoriser result, source IP, route and status code for every stage. Make sure tokens and API keys are not written in full.
  • Authoriser failures. A rising rate of 401 and 403 responses from one source often means credential stuffing or a leaked token being tested.
  • Control plane changes via CloudTrail: new or modified authorisers, resource policy updates, stage deployments, routes switched to no authorisation, and API key creation or export.
  • AWS Config rules and Security Hub CSPM controls for API Gateway, to catch stages without logging, without WAF or without the expected settings.
  • Unusual callers. A role or token calling routes it has never called before is a strong signal of a compromised workload.

Map detections to MITRE ATT&CK for reporting: Exploit Public-Facing Application for attacks on exposed routes and Valid Accounts: Cloud Accounts for misuse of stolen roles and tokens. CloudTrail alerting patterns are covered in our Amazon CloudWatch Security Guide.

Common failure patterns

  • API keys used as the only control. A key in a mobile app is extracted and used to call every API in the shared usage plan.
  • Lambda authoriser cache bleed. A method-scoped Allow is cached and reused across other methods, granting or blocking access incorrectly.
  • JWT routes without scopes. Any valid token for the audience, including an ID token, is accepted.
  • Private API open to every VPC endpoint. The resource policy allows * with no aws:SourceVpce condition, so any account with an endpoint can call it.
  • IP rules with the wrong condition key. aws:SourceIp used on a private API, so the rule never matches the real caller.
  • Policy approved but not deployed. The resource policy in source control differs from the deployed stage.
  • Throttling treated as a cost cap. A burst exceeds the quota and runs up back-end and data transfer costs.
  • Over-privileged deployment role. A CI role that can deploy any API can also strip any authoriser.
  • Authoriser that fails open. An exception path returns Allow, or a timeout is retried without a decision.

Practitioner checklist

  • Inventory every API, stage and route with its API type, authoriser, resource policy and owner.
  • Remove or justify every route with authorisation type NONE.
  • Use IAM authorisation for AWS callers and scope execute-api:Invoke to stages, methods and paths.
  • Require scopes on every JWT authoriser route and keep audience lists to the clients that need them.
  • Make Lambda authoriser policies valid for every cached resource, or add path and method to the REQUEST cache key.
  • Make authoriser functions fail closed, with least-privilege execution roles and no secrets in context.
  • Attach a resource policy to every REST API; pin private APIs with aws:SourceVpce and use aws:VpcSourceIp for IP rules.
  • Apply VPC endpoint policies that limit which APIs each endpoint can reach.
  • Treat API keys as metering only, rotate and expire them, and split usage plans by audience.
  • Put AWS WAF in front of public stages and use AWS Budgets for spend alerts.
  • Enable access logging, CloudTrail, AWS Config and Security Hub CSPM controls; alert on authoriser and policy changes.
  • Restrict who can change authorisers, resource policies and stages, and review that list quarterly.

Standards and references

Related NHI Mgmt Group resources: API Gateway Security Guide · How to audit API gateway keys and usage plans · AWS Access Keys Security Guide · Amazon Cognito Security Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.