Introducing a new way to review your PRs.

Read the announcement

floci-io / floci

Light, fluffy, and always free - The AWS Local Emulator alternative

View on GitHub

38 documents · Updated Nov 23, 2026

docs / svc-api-gateway

API Gateway

API Gateway provides AWS-shaped control planes for REST APIs, HTTP APIs, and WebSocket APIs. It turns an API definition into a managed request path: a caller reaches an API stage, the gateway selects a method or route, checks access and input rules, and sends the request to Lambda, an AWS service, an HTTP backend, or a mock response. The management surface also imports and exports OpenAPI definitions so API configuration can move between this service, CloudFormation, and other AWS-shaped tools. Request matching relates to request routing and protocols, authentication to IAM and authentication, Lambda targets to Lambda execution platform, and declarative API setup to CloudFormation.

API Gateway control planes

The control planes describe the resources that make an API callable. REST APIs use a resource tree with methods and integrations. HTTP APIs use route keys that point to integrations. WebSocket APIs use lifecycle and message routes. These definitions are separate from the data plane that handles user traffic.

REST API resources

The REST control plane models an API as a root resource plus child paths. Each resource can declare an HTTP method, authorization rule, request validator, method responses, and one integration. Deployments and stages make that definition available at an invoke path.

REST methods can carry authorization scopes for Cognito user-pool access tokens. OpenAPI import can create the resource tree, authorizers, scopes, integrations, request validators, models, and gateway responses. A deployment captures a point-in-time API view, so later edits do not change the definition associated with that deployment.

REST APIs also carry an API policy, endpoint configuration, binary media types, and an API key source. Binary media types affect how bodies move through an integration. API keys can come from the x-api-key header or from a Lambda authorizer's usageIdentifierKey.

Management PATCH requests use a shared patchOperations envelope. The boundary accepts only the modeled operation names before a resource-specific update handles the operation.

REST management collections such as authorizers, request validators, and documentation parts can be read in pages. A caller uses a limit and a continuation position to move through a stable identifier-ordered list.

References: src/…/ApiGatewayService.java• L324-405 src/…/ApiGatewayService.java• L1267-1285 src/…/ApiGatewayService.java• L2369-2376 src/…/ApiGatewayController.java• L110-151 src/…/ApiGatewayController.java• L279-301 src/…/RestApi.java• L13-46

REST API documentation

REST APIs can store documentation parts that describe API resources, methods, request data, and responses. The management API supports creating, listing, updating, and deleting these parts. Requests use the API Gateway documentation shapes and return a bad-request error when their values do not match the modeled type, range, pattern, or required-field rules. List requests support bounded pages with a continuation position.

References: src/…/ApiGatewayController.java• L1225-1287 src/…/ApiGatewayService.java• L2570-2590 src/…/ApiGatewayDocumentationRequestShapes.java• L9-50

HTTP API routes

The HTTP API control plane uses a route key such as GET /users/{id} or $default. A route points to an integration and may select IAM, JWT, or Lambda request authorization. Stages make the route set callable. OpenAPI import creates the API, routes, integrations, security rules, and CORS settings.

Creating an HTTP API with a target can also create a default integration, a $default route, and an auto-deployed $default stage. This quick-create path makes the supplied Lambda or HTTP target callable without separate route and stage setup.

HTTP API integrations support Lambda proxy and HTTP proxy work. They can also use an integration subtype to map a route request to a supported AWS service action. The subtype, payload format, credentials, and request parameter mappings are part of the integration contract. Request parameter sources can use request fields, including the request path without its stage and captured path parameters, stage variables, authorizer data, and request context.

HTTP API integration responses can also map a backend result to a new status or to response headers. The mapping is selected by backend status and can read backend headers, the body, JSON body values, or gateway context. Header actions include overwrite, append, and remove.

HTTP APIs also support models, custom domains, API mappings, VPC links, and a disabled execute endpoint. Their schemas describe the API but do not enable the REST request-validator path. API mappings share custom-domain records with REST APIs while retaining the API type needed for later routing.

References: src/…/ApiGatewayController.java• L1392-1487 src/…/ApiGatewayController.java• L1510-1623 src/…/ApiGatewayExecuteController.java• L2855-2895 src/…/ApiGatewayV2Service.java• L83-168 src/…/ApiGatewayV2Service.java• L785-825 src/…/ApiGatewayV2Service.java• L1006-1055 src/…/AwsServiceIntegrationMapper.java• L23-36 src/…/ContextValueResolver.java• L22-35

WebSocket API sessions

WebSocket APIs keep a live connection between a client and an API stage. The connection has $connect and $disconnect lifecycle routes. A route selection expression chooses a message route, with $default handling messages that do not match a configured route.

The @connections management API lets server-side code send a message, read connection information, or close a connection. These calls use the shared execute-api path, while the WebSocket handler owns the handshake and live message flow. A management message is limited to 128 KiB. An inactive connection returns GoneException.

References: src/…/ApiGatewayExecuteController.java• L217-281 src/…/ApiGatewayExecuteApiHostFilter.java• L205-215 src/…/ApiGatewayExecuteApiHostFilter.java• L397-403

OpenAPI import and export

OpenAPI import turns a Swagger 2.0 or OpenAPI 3 document into REST resources, methods, security rules, models, validators, integrations, and gateway responses. Import can create a new API or merge into an existing API. Overwrite replaces the existing REST definition. Warnings can be returned or made fatal with failonwarnings.

HTTP API import follows the v2 envelope and can create or replace an API with its routes and integrations. It reads API Gateway extensions for integrations, authorizers, any-method routes, and CORS. It validates integration subtypes and their request parameters before an import changes the API. On reimport, the existing HTTP routes, integrations, and authorizers are replaced only after the new document passes planning and warning checks.

REST export reads the snapshot attached to the stage's deployment and produces Swagger 2.0 or OpenAPI 3.0.1. Export extensions control whether integrations, authorizers, and API Gateway vendor extensions appear in the document. A deployment without an export snapshot must be replaced by a new deployment before export.

References: src/…/ApiGatewayService.java• L878-932 src/…/ApiGatewayService.java• L4083-4190 src/…/RestApiOpenApiExporter.java• L26-163 src/…/ApiGatewayController.java• L1394-1487 src/…/ApiGatewayV2OpenApiImporter.java• L64-149 src/…/ApiGatewayV2OpenApiImporter.java• L667-717

Custom domain mappings

Custom domains provide an alternate public name for an API. The gateway finds a domain by its registered name or regional host name, then uses the longest matching base path mapping to select the API and stage. It removes that base path before normal execution.

REST base path mappings and HTTP API mappings share domain records, but each mapping retains the API type so the request enters the correct control plane. Domain routing also carries the owning account and region into data-plane execution. Before the URI is rewritten to the shared execute-api form, the gateway records the caller's raw path for IAM signature checks. A request that was already routed is marked so a later host filter does not rewrite it again.

References: src/…/ApiGatewayCustomDomainFilter.java• L56-127 src/…/BasePathMapping.java• L8-42 src/…/ApiGatewayExecuteRouteContext.java• L78-134

Invoke request flow

The data plane accepts direct execute-api paths, execute-api virtual hosts, local AWS-shaped hosts, and custom-domain hosts. Host routing resolves the API, owning account, region, and stage. It records the route choice in request-scoped context and rewrites the request into a shared execution path. IAM checks still use the caller-visible path rather than the rewritten internal path.

The request follows a common sequence:

  1. Resolve the API, region, account, and stage.
  2. Match a REST resource and method or an HTTP route.
  3. Apply authorization and API key checks.
  4. Validate required parameters or a REST request body when configured.
  5. Resolve the target integration.
  6. Transform and dispatch the request.
  7. Transform the integration result or render a gateway-generated response.

This diagram shows how a caller request becomes an integration result or a gateway response.

flowchart LR
    A[Client request] --> B[Host and API lookup]
    B --> C[Stage and resource or route match]
    C --> D[Authorization]
    D --> E[API key and request validation]
    E --> F[Integration selection]
    F --> G[Lambda, AWS service, HTTP backend, or mock]
    G --> H[Integration response]
    C --> I[Gateway response]
    D --> I
    E --> I
    F --> I

Host routing

The execute-api host filter recognizes local, built-in, AWS-shaped, and region-bearing execute-api host names. It resolves API ownership before it chooses the protocol. HTTP APIs route invoke traffic through the filter. WebSocket APIs use it only for @connections management calls. The WebSocket handshake uses the live connection path.

The filter takes the region from the host when possible, then from a SigV4 credential scope, and finally from an API-owner lookup. It chooses the named stage when the first path segment is a real stage. Otherwise it uses $default when that stage exists. A disabled HTTP API execute endpoint returns 404 before route execution.

The request-scoped route context keeps source and local addresses, request identifiers, API type, mapped domain, raw signed path, and rewritten path. Downstream events and proxy mappings can therefore report the caller's source address while internal dispatch uses the shared execute-api URI.

References: src/…/ApiGatewayExecuteApiHostFilter.java• L114-287 src/…/ApiGatewayExecuteRouteContext.java• L31-134 src/…/ApiGatewayExecuteController.java• L3188-3202

REST resource matching

REST matching ranks exact resources above named path parameters and greedy terminal parameters. It compares all matching candidates before it selects a method. A more specific resource that lacks the requested method can yield to a less specific resource that declares it or ANY.

Matching uses a normalized path. A trailing slash is recovered for authorizer and proxy event paths, but it does not change the resource or path-parameter match. Named parameters and the remainder of a greedy parameter flow into authorizer events, proxy events, VTL mappings, request mappings, and integration URI substitutions.

If no candidate declares the requested method, REST returns the gateway-generated MISSING_AUTHENTICATION_TOKEN response. It does not call an integration.

References: src/…/ApiGatewayExecuteController.java• L454-487 src/…/ApiGatewayExecuteController.java• L3323-3343

HTTP route matching

HTTP route matching checks an exact METHOD path key, then a path template, and then $default. A route target identifies the integration that receives the request. An HTTP API without a matching route returns 404 with a Not Found message.

The shared v2 path enforces the execute endpoint setting before route matching and resolves the route target before dispatch. An HTTP route with AWS_IAM verifies the signed request before it reaches authorization or integration dispatch. When CORS is configured, an unmatched OPTIONS request can receive an API-generated preflight response. A matched route still runs its authorizer and integration before CORS headers are applied.

References: src/…/ApiGatewayExecuteController.java• L2855-2895 src/…/ApiGatewayExecuteController.java• L2897-2954 src/…/ApiGatewayExecuteApiHostFilter.java• L205-239 src/…/ApiGatewayV2Service.java• L680-783

Request identity and event data

The gateway creates request identity data once for the execution path. REST proxy events include route data, caller identity, API key identity, authorizer context, repeated headers and query values, stage variables, and the request body. A configured binary media type sends the body as base64 data.

HTTP API Lambda events use payload format 1.0 or 2.0. Format 2.0 combines repeated headers and query values and exposes cookies separately. Both formats carry route data, request time, source information, stage data, and verified authorization claims when the route uses JWT, Lambda, or IAM authorization. The caller source address also flows into HTTP API event identity and proxy request context.

The caller-visible path and the normalized path have different roles. Matching and path parameters use the normalized path. Proxy and authorizer events preserve a caller-sent trailing slash. IAM verification uses the signed path captured before host rewriting.

References: src/…/ApiGatewayExecuteController.java• L1342-1369 src/…/ApiGatewayExecuteController.java• L3950-4047 src/…/ApiGatewayExecuteController.java• L3715-3765 src/…/ApiGatewayExecuteRouteContext.java• L113-134

Access control and request checks

API Gateway separates the decision to admit a request from the work performed by an integration. REST methods and HTTP routes can require IAM or a configured authorizer. REST methods can also require an API key. Request validators apply after authorization and usage checks and before the integration runs.

IAM authorization

AWS_IAM requires SigV4 authentication. The gateway accepts a header-signed request or a presigned query request. It checks the credential scope, signed host, time window, caller-visible path, body hash, and derived signature. Temporary credentials must also provide the issued session token.

The check requires a registered active credential, plus the local test/test development credential. The signed headers must include host. A verified caller identity is added to REST and HTTP API proxy events. Custom-domain routing does not change the path used for signature verification. The gateway verifies credentials but does not evaluate execute-api:Invoke against IAM policies or an API resource policy. See IAM and authentication for the distinction between credential verification and policy decisions.

REST IAM failures use a gateway response with status 403 and an AWS error type. HTTP API IAM failures use 403 with a simple Forbidden body.

References: src/…/ExecuteApiSigV4Authorizer.java• L23-49 src/…/ExecuteApiSigV4Authorizer.java• L107-195 src/…/ApiGatewayExecuteController.java• L496-507 src/…/ApiGatewayExecuteController.java• L2902-2913

Lambda and JWT authorizers

REST custom authorizers invoke Lambda with a token or request event. The result must contain a non-empty principal and a policy that permits the requested execute-api:Invoke method ARN. A deny, invalid result, or authorizer failure stops the integration call. Authorizer context then flows into proxy events and VTL mappings.

REST authorizer results can be cached by identity source, stage deployment, and configured TTL. A Lambda authorizer can return usageIdentifierKey; when the REST API takes its key from the authorizer, that value becomes the API key used for the later usage check.

HTTP APIs can use a Lambda request authorizer or a JWT authorizer. JWT authorization verifies the token signature and configured issuer before the route runs. It then checks expiry, audience, and configured route scopes. Verified claims and the token's full scope list flow into the v2 Lambda event and request-parameter context.

References: src/…/RestLambdaAuthorizer.java• L19-79 src/…/RestLambdaAuthorizer.java• L99-165 src/…/ApiGatewayExecuteController.java• L1086-1158 src/…/ApiGatewayExecuteController.java• L2915-2933 src/…/ContextValueResolver.java• L57-99

Cognito user-pool authorization

COGNITO_USER_POOLS authorizers admit REST requests when a bearer token verifies against one of the configured provider pools. The authorizer reads the configured identity header, checks the token's pool, and exposes the verified principal and claims to the integration.

When a method declares authorization scopes, the token must be an access token with at least one required scope. Missing, invalid, or insufficient token data returns 401 and stops the integration call.

References: src/…/CognitoUserPoolAuthorizer.java• L19-86 src/…/ApiGatewayExecuteController.java• L1092-1105

API keys and usage plans

An API key is usable on the data plane only when it is enabled and linked to a usage plan that covers the API and stage. When a method sets apiKeyRequired, a missing or unusable key produces a gateway response after authorization and before request validation or integration execution. A usable key is also metered on every call that resolves to it, even when the method does not require an API key.

Usage plans describe attached API stages, plan-wide throttle limits, optional per-method stage limits, and quota periods. An admitted call first consumes a plan throttle token, then counts against the plan quota. A rejected throttle call returns 429 with a throttling response. A call beyond the quota returns 429 with a quota response. Per-method stage throttle values are retained as plan data but are not enforced by request execution.

Usage reports return per-key daily counts and remaining quota for the requested inclusive date range. Reports page by key and use a continuation position when more keys remain. The wire response places daily pairs under values, with each pair containing used calls and remaining quota. A plan without a quota reports zero use and zero remaining. Deleting an API key removes its usage-plan associations and stored usage counts. A Lambda authorizer can supply the key value when the REST API uses AUTHORIZER as its key source.

References: src/…/ApiGatewayExecuteController.java• L490-531 src/…/ApiGatewayController.java• L985-1030 src/…/ApiGatewayService.java• L1560-1573 src/…/ApiGatewayService.java• L1864-1927 src/…/UsagePlanLimits.java• L22-110

Request validation

REST request validators can require declared query or header parameters and can validate a request body against a named model. Missing parameters and invalid bodies become gateway responses before the integration runs. The model used for body validation comes from the stage's deployment view. HTTP API OpenAPI schemas remain API descriptions and do not enable this REST validation path.

References: src/…/ApiGatewayExecuteController.java• L1218-1315 src/…/RequestValidator.java• L8-34 src/…/Model.java• L8-31

Integration execution

An integration is the bridge from a matched API operation to a target system. Proxy integrations preserve most of the incoming request. Non-proxy integrations use explicit mappings and can select response rules. REST and WebSocket APIs share the broad integration types, while HTTP API routes use the v2 integration model.

Lambda proxy dispatch

AWS_PROXY sends a structured event to Lambda and expects a proxy response. The event includes route data, headers, query parameters, path parameters, stage data, request context, authorization context, and the body. Repeated headers and query values remain available in multi-value fields for REST payloads.

The returned status, headers, cookies where supported, and body become the caller response. Function errors, missing functions, and malformed proxy payloads become gateway integration failures. Lambda execution is supplied by the Lambda service; see Lambda execution platform.

HTTP API Lambda proxy routes support payload format 1.0 and 2.0. Format 2.0 uses lower-case combined headers, a separate cookie list, and nested JWT, Lambda, or IAM authorizer context.

References: src/…/ApiGatewayExecuteController.java• L598-635 src/…/ApiGatewayExecuteController.java• L2961-2991 src/…/ApiGatewayExecuteController.java• L3895-4054

AWS service dispatch

AWS integrations render a request mapping and send the result to an AWS-shaped service target. Action-style URIs carry the operation in the URI and use a JSON body. Path-style URIs carry the operation in the rendered AWS query-protocol body.

The service router connects supported API Gateway targets to internal AWS-shaped service handlers. Integration responses can match errors or backend status, select a status, render a response template, and map response values to method headers. An unsupported service, missing action, invalid URI, or failed target becomes an integration or configuration error.

References: src/…/ApiGatewayExecuteController.java• L1865-2060 src/…/AwsServiceRouter.java• L87-209

HTTP API AWS service integrations

An HTTP API can use an AWS_PROXY integration subtype to call a supported AWS service action without a Lambda function. The route maps request headers, query values, path values, body fields, stage variables, authorizer values, and request context into named action parameters. The request path source is the path without the stage name. The gateway selects the action region from the mapped Region value or from the API request region.

The integration contract requires payload format 1.0, a known subtype, all required action parameters, and only parameters accepted by that action. JSON action members must be JSON objects or supported source expressions. Embedded expressions resolve inside string values, while missing optional sources become empty or omitted values according to the action parameter. The service result is returned in the action response envelope. An action error keeps the service error code, message, status, and request ID.

The model knows all AWS-defined subtype names, but only subtypes with a locally supported service action are invocable. A known but unsupported subtype remains a valid control-plane value and fails when a request reaches it.

References: src/…/Integration.java• L10-26 src/…/IntegrationSubtype.java• L9-18 src/…/ApiGatewayExecuteController.java• L2994-3063 src/…/AwsServiceIntegrationMapper.java• L47-73 src/…/AwsServiceIntegrationMapper.java• L124-183 src/…/ContextValueResolver.java• L58-125 src/…/AwsServiceIntegrationMapper.java• L184-261

HTTP proxy dispatch

HTTP_PROXY forwards the request to an arbitrary HTTP backend. It applies configured path, header, and query mappings while preserving repeated values. The backend status, headers, and body return to the caller without integration-response selection. Hop-by-hop headers are not forwarded, and repeated response headers remain separate.

HTTP API response parameter mappings run after the backend response arrives. A status-specific mapping can overwrite the status or change response headers by appending, overwriting, or removing values. Sources can read backend headers, the response body, a JSON path in that body, or request context. Invalid mapped header values are skipped rather than sent to the caller.

Transport failures, invalid mapped headers, and timeouts return 502. The proxy verifies backend certificates by default and can use an integration timeout and tlsConfig.insecureSkipVerification where configured. That TLS setting allows private or self-signed roots while retaining certificate validity, hostname, and chain checks. The proxy also blocks metadata-service targets and connects to the address that passed the metadata check, which prevents a second DNS lookup from changing the target. Backend response bodies are bounded by the API Gateway payload limit. HTTP API proxy routes can target an Application Load Balancer listener or a Cloud Map service. The gateway resolves those targets before forwarding and checks VPC link availability when required.

REST proxy integrations default to a 29-second timeout. HTTP API proxy integrations use a 30-second default. HTTP API proxy dispatch also adds the caller source address and gateway forwarding context to the backend request while preserving the original request values used by parameter mappings.

References: src/…/ApiGatewayExecuteController.java• L647-732 src/…/ApiGatewayExecuteController.java• L3092-3223 src/…/ApiGatewayExecuteController.java• L3268-3284 src/…/ResponseParameterMapper.java• L11-105 src/…/HttpProxyInvoker.java• L42-82 src/…/HttpProxyInvoker.java• L308-430 src/…/PinnedHttpClient.java• L21-39

HTTP mapped dispatch

HTTP integrations build the backend request from explicit parameter mappings and VTL request templates. Unmapped inbound headers and query values do not reach the backend. The backend result then passes through integration-response selection and response mapping.

Request templates are selected by the incoming content type. Passthrough rules decide whether an unmatched body can continue without a template. Response selection matches the backend HTTP status for HTTP integrations. Content handling can convert binary data between text and bytes.

References: src/…/ApiGatewayExecuteController.java• L964-1093 src/…/ApiGatewayExecuteController.java• L2071-2249 src/…/Integration.java• L13-30

Mock integration responses

MOCK integrations do not call a backend. A request template renders a status code that selects an integration response. That response can render a body and headers, which makes a mock useful for fixed replies such as CORS preflight responses.

If no output mapping exists, the emulator keeps a bare mock as an empty 200 response. If a rendered status has no matching or default integration response, the gateway returns a configuration error.

References: src/…/ApiGatewayExecuteController.java• L2465-2577 src/…/IntegrationResponse.java• L8-23

WebSocket integration dispatch

WebSocket routes use the same broad integration choices as REST routes: Lambda proxy, mapped Lambda or AWS service calls, HTTP proxy, mapped HTTP, and mock responses. The WebSocket invoker substitutes stage variables and applies VTL request or response mapping where the integration needs it, then returns the result to the connection lifecycle.

WebSocket HTTP proxy and mapped HTTP integrations send the transformed event to the target and preserve the backend status and body. HTTP targets use the shared bounded transport and metadata-address safeguards. Lambda proxy results can also supply headers for the connection handshake, while route messages receive the integration result through the WebSocket handler.

References: src/…/WebSocketIntegrationInvoker.java• L130-161 src/…/WebSocketIntegrationInvoker.java• L164-384 src/…/WebSocketIntegrationInvoker.java• L387-527

Response caching

REST response caching applies only when the stage cache cluster is enabled and the method setting enables caching. The cache key uses the integration namespace and configured request parameters. Successful responses use the method TTL or a five-minute default. Error responses are not cached.

Stage variables can affect integration URIs and template processing. Stage settings also carry method caching, access-log, tracing, and throttling configuration. Plan usage controls reject traffic. Stage method throttle settings describe per-method limits but are not applied by the execution path.

References: src/…/ApiGatewayExecuteController.java• L735-832 src/…/Stage.java• L11-24 src/…/MethodSetting.java• L19-34

Velocity mapping templates

Velocity Template Language (VTL) is the mapping language for non-proxy REST integrations, mock integrations, and gateway response bodies. It combines request or integration data with headers, query values, path values, stage variables, authorizer context, and gateway error context.

Templates use $input for body and parameter access, $util for encoding and JSON helpers, and $context for request metadata and response overrides. Gateway response templates also receive error fields such as the message, response type, and validation detail.

VTL runs in a restricted sandbox. The gateway bounds loop work, output size, and evaluation time. Templates cannot use reflection, process execution, threads, sockets, scripting, or host file access. A template failure becomes an integration or gateway error at the stage where it occurs.

References: src/…/VtlTemplateEngine.java• L39-135 src/…/VtlTemplateEngine.java• L137-228 src/…/VtlSandbox.java• L30-99 src/…/VtlExecutionGuard.java• L23-49 src/…/BoundedWriter.java• L6-34

Gateway-generated responses

Gateway responses are produced by API Gateway before or instead of an integration result. REST APIs can customize a response type, status, headers, and body templates. A specific customization takes priority over its DEFAULT_4XX or DEFAULT_5XX fallback. If no customization applies, the normal gateway error body remains in use.

Response parameter mappings can copy request, context, or stage values into gateway response headers. Gateway response templates can read request values and error fields. This lets an API add headers such as CORS headers to errors. A template failure falls back to the default gateway body. Backend-owned error statuses from HTTP_PROXY remain backend responses rather than gateway responses.

Common gateway-generated conditions include:

  • no matching resource, method, or route;
  • invalid IAM credentials or authorizer denial;
  • a missing usable API key;
  • a throttled or over-quota usage plan;
  • request parameter or body validation failure;
  • unsupported media type from passthrough rules;
  • missing or invalid integration configuration;
  • an unavailable VPC link;
  • Lambda integration failure or malformed proxy output.

References: src/…/ApiGatewayExecuteController.java• L3288-3356 src/…/ApiGatewayExecuteController.java• L4109-4185 src/…/ApiGatewayExecuteController.java• L4187-4350 src/…/ApiGatewayController.java• L1047-1110 src/…/GatewayResponseType.java• L7-55

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep execute-api host recognition aligned with API ownership, region selection, protocol type, stage selection, disabled endpoints, and the distinction between HTTP traffic and WebSocket @connections traffic.
  • Keep custom-domain mapping identity aligned between API type, owning account, region, base-path stripping, route context, and the raw path used for IAM signatures.
  • Keep route context aligned with request IDs, source and local addresses, raw signed paths, rewritten paths, and the proxy or authorizer event fields that consume them.
  • Keep REST resource ranking aligned with method fallback, terminal greedy parameters, trailing-slash event paths, path parameter extraction, and integration URI substitution.
  • Keep HTTP route dispatch aligned with IAM checks, JWT claim and scope propagation, Lambda request authorizers, CORS preflight rules, and disabled execute endpoints.
  • Keep authorizer results aligned with proxy events, VTL $context.authorizer, WebSocket events, and usageIdentifierKey API-key resolution.
  • Keep API key enablement and usage-plan stage membership aligned with apiKeyRequired enforcement.
  • Keep usage-plan throttle and quota admission aligned with usage report counters, key and plan deletion cleanup, pagination, and with the order of authorization, key checks, throttle, quota, and request validation.
  • Keep management collection paging aligned with accepted limit values, continuation positions, identifier ordering, and the response position field.
  • Keep REST PATCH boundary validation aligned with the accepted operation names and the resource-specific update handlers.
  • Keep request-template media-type selection aligned with passthrough behavior and response content handling.
  • Keep Lambda proxy response handling aligned with REST and HTTP API payload formats, cookies, binary bodies, default content types, and gateway failures.
  • Keep REST and HTTP API response parameter mappings aligned with status selection, source expressions, case-insensitive headers, append or overwrite behavior, and header validation.
  • Keep gateway response fallback selection aligned with response types, status codes, header sources, error context, and VTL fallback behavior.
  • Keep HTTP proxy transport safeguards aligned with repeated headers, TLS checks, custom CA use, metadata-address rejection, ALB and Cloud Map resolution, VPC link checks, timeout defaults, bounded responses, and 502 conversion.
  • Keep VTL context fields and execution limits aligned across request templates, integration responses, mock responses, gateway responses, and WebSocket integrations.
  • Keep SigV4 canonicalization aligned with raw paths, raw queries, the signed host, body hashes, clock limits, presigned expiry, and session tokens.
  • Keep OpenAPI import and export aligned on vendor extensions, security scheme names, model references, validator names, integration type names, and deployment snapshots.
  • Keep HTTP API integration subtype validation aligned between management requests, OpenAPI extensions, payload format 1.0, parameter source expressions, required action members, and the service response envelope.
  • Keep documentation-part request checks aligned with the service model and with the v1 documentation-part management operations.

Important failure modes

TriggerConsequenceGuard
An execute-api host names an API in the wrong region or accountThe request is not routed or returns an ownership conflictResolve the API owner and region before choosing the control plane
A request is already rewritten but a host filter rewrites it againThe internal path gains a second execute-api prefix and returns 404Record the routed state and ignore internal execute-api paths in host routing
A custom-domain request signs the rewritten pathA valid IAM request fails authorizationPreserve the caller-visible raw path for SigV4 verification
HTTP API execute endpoint is disabledDirect or virtual-host execution returns 404Enforce the setting at the shared v2 dispatch point
A WebSocket data connection is sent through HTTP route dispatchThe handshake or message flow does not reach the WebSocket handlerRoute only @connections management calls through execute-api host handling
REST has no resource or method for the requestGateway returns Missing Authentication Token and no integration runsMatch all candidates and their methods before returning the REST gateway response
A specific REST resource lacks the requested methodA less specific resource may be skipped incorrectlyRank resources first, then select the first candidate with the method or ANY
A trailing slash is dropped from the delivered eventA backend router treats /x and /x/ as different pathsMatch the normalized path but restore the slash in event and authorizer paths
An HTTP API IAM route receives an unsigned requestThe request reaches the integration without authorizationEnforce SigV4 before v2 integration dispatch
A SigV4 request omits host from its signed headersThe request is not bound to one API host and is rejectedRequire host in the signed header set
A JWT token fails signature, issuer, audience, expiry, or scope checksHTTP API returns 401 or 403 and does not invoke the integrationVerify the token before trusting claims and enforce route scopes
A Lambda authorizer returns an invalid policy or contextGateway denies or fails the request before integration executionValidate the authorizer result and evaluate its method ARN
API key is missing, disabled, deleted, or not linked to the API stageA required-key method returns an invalid API key responseResolve only enabled keys attached through a covering usage plan
A usage plan throttle or quota is exhaustedThe request returns 429 and does not reach validation or integrationMeter the admitted key after authorization and before dispatch
Per-method usage-plan throttle is configuredThe plan reports the setting but execution does not reject by that settingTreat plan-wide throttle and quota as the enforced data-plane controls
A management list uses an invalid limit or continuation positionThe management call returns a bad-request error instead of a pageValidate the page size and accept only a position from the ordered collection
A PATCH request uses an unknown operation nameThe management call is rejected instead of silently leaving the resource unchangedValidate the operation against the shared API Gateway operation set
Request validation failsGateway returns a validation response before integration executionApply the configured validator after authorization and usage admission
Lambda proxy returns a function error or malformed payloadGateway returns an integration failureParse the proxy envelope and route gateway-owned failures through gateway response handling
HTTP backend cannot be reached or times outCaller receives 502Apply bounded transport waits and convert transport failures to proxy failures
HTTP backend certificate fails validity, hostname, or chain checksThe proxy refuses the call even when CA trust is relaxedKeep certificate validity and hostname checks enabled when insecureSkipVerification is used
HTTP backend resolves to a metadata-service addressThe proxy refuses the callReject metadata targets after host resolution and connect to the checked address
An HTTP API response mapping names an invalid status, header, or sourceThe integration cannot be created or updated with a valid response contractValidate status keys, header names, and response parameter forms before persistence
An HTTP API response mapping produces an invalid header valueThe mapped value is not sent to the callerValidate mapped response headers and skip invalid values
A mapped HTTP header has an invalid name or control characterThe proxy returns 502 without sending the requestValidate mapped headers before transport
An HTTP backend response exceeds the payload quota or has invalid chunk framingThe proxy returns a size or transport errorBound all response framing paths and validate chunk endings
VPC link is missing or unavailableREST or HTTP API integration returns a configuration or 502 failureValidate the link identifier and availability before dispatch
An HTTP API subtype has missing, extra, or unsupported parameter mappingsThe integration is rejected at creation or update, or the request returns a parameter errorValidate subtype names, payload format, required members, source expressions, and JSON members together
A known HTTP API subtype has no locally supported action handlerThe route returns an internal service errorCheck invocability before dispatch and use a supported subtype
VTL output exceeds its size or time limitMapping fails and the gateway or integration returns an errorUse bounded output and evaluation guards
MOCK status has no matching or default integration responseGateway returns a configuration errorSelect by rendered status, then fall back to the default response
A gateway response template failsThe configured body is discardedFall back to the default gateway body while keeping the gateway status
REST export targets a deployment without an export snapshotExport fails instead of describing mutable API stateCreate a new deployment before exporting the stage
OpenAPI import names an unknown integration type or unresolved security schemeThe integration or security rule is skipped and a warning is recordedUse a supported canonical type or authorizer, or enable warning failure
An HTTP API reimport fails warning or subtype validation after partial replacementThe API can lose its previous routes or integrationsPlan and validate the document before replacing the existing definition
A documentation-part request violates a modeled shapeThe management call returns BadRequestExceptionApply the pinned documentation request-shape checks before persistence

Key files

FileWhy to read it
src/…/ApiGatewayService.javaREST API lifecycle, deployments, stages, OpenAPI import and export, authorizers, keys, usage plans, gateway responses, domains, and ownership state
src/…/ApiGatewayController.javaREST and v2 management API boundary, OpenAPI operations, mappings, gateway responses, usage reports, documentation parts, and resource descriptions
src/…/ApiGatewayDocumentationRequestShapes.javaValidation rules for REST documentation-part requests
src/…/ApiGatewayExecuteController.javaShared request execution, REST and v2 matching, authorization, validation, VTL mapping, caching, proxy dispatch, WebSocket management, AWS service subtypes, CORS, usage admission, and gateway responses
src/…/ApiGatewayExecuteApiHostFilter.javaExecute-api virtual-host lookup, API ownership, region and stage selection, protocol routing, endpoint checks, and signed-path preservation
src/…/ApiGatewayCustomDomainFilter.javaCustom-domain lookup, longest-prefix mapping, base-path stripping, API type selection, ownership context, and routing into API execution
src/…/ApiGatewayExecuteRouteContext.javaRequest-scoped API route, request identity, source address, raw signed path, and rewritten path
src/…/ExecuteApiSigV4Authorizer.javaIAM data-plane authentication, signed request checks, credential state, expiry rules, session tokens, and caller identity
src/…/RestLambdaAuthorizer.javaREST Lambda authorizer result validation, cache scope and expiry, stage flush behavior, and usage identifier keys
src/…/CognitoUserPoolAuthorizer.javaCognito token, provider-pool, access-scope, principal, and claims checks
src/…/VtlTemplateEngine.javaVTL request, response, gateway context, response overrides, and evaluation limits
src/…/AwsServiceRouter.javaURI parsing and dispatch from AWS integrations to AWS-shaped service handlers
src/…/RestApiOpenApiExporter.javaREST deployment snapshot conversion to Swagger 2.0 and OpenAPI 3.0.1
src/…/UsagePlanLimits.javaUsage-plan stage, throttle, quota, and patch rules
src/…/UsagePlan.javaUsage-plan stages, plan-wide limits, and quota model
src/…/GatewayResponse.javaREST gateway response customization and default response shape
src/…/Integration.javaREST integration types, mappings, templates, transport settings, and cache keys
src/…/ApiGatewayV2JsonHandler.javaHTTP and WebSocket management action dispatch and v2 integration request and response shapes
src/…/ApiGatewayV2Service.javaHTTP and WebSocket API resources, route targets, stages, integration contracts, response parameter validation, and v2 route matching
src/…/ApiGatewayV2OpenApiImporter.javaHTTP API OpenAPI planning, security binding, integration extension mapping, subtype validation, and replacement behavior
src/…/Integration.javaHTTP API integration contract, payload format, credentials, request mappings, response mappings, and templates
src/…/IntegrationSubtype.javaSupported HTTP API AWS service actions and their parameter and result contracts
src/…/AwsServiceIntegrationMapper.javaHTTP API request-parameter resolution and AWS service action request and response envelopes
src/…/ContextValueResolver.javaHTTP API source expressions for request data, stage variables, authorizer values, and context
src/…/RequestContext.javaSingle-value and repeated request data, decoded and raw path parameters, source address, and mapping context
src/…/RequestParameterMapper.javaHTTP API path, header, and query transformations
src/…/ResponseParameterMapper.javaHTTP API backend response status and header transformations
src/…/HttpProxyInvoker.javaHTTP backend transport, TLS and CA behavior, timeouts, metadata safeguards, headers, and response boundaries
src/…/PinnedHttpClient.javaChecked-address connections, HTTP response framing, header checks, and payload limits
src/…/WebSocketIntegrationInvoker.javaWebSocket integration target dispatch, stage variables, VTL mapping, bounded HTTP transport, and handshake response headers
src/…/WebSocketHandler.javaWebSocket connection and message lifecycle