Closes#7998
Validate description types before creating or changing an integration so malformed JSON returns BadRequestException instead of an uncaught ClassCastException. Preserve omitted, null and empty-string behavior. Cover create and update over REST and JSON 1.1, including rejection without stored changes.
CreateIntegration, UpdateIntegration, GetIntegration(s), OpenAPI import and
AWS::ApiGatewayV2::Integration now carry IntegrationSubtype. A subtype is
accepted only on an HTTP API AWS_PROXY integration with payload format 1.0
(the default when a subtype is set), and its RequestParameters must map every
required member of the action and nothing it does not take. SQS-SendMessage is
the supported subtype. The JSON 1.1 path keeps RequestParameters keys as sent,
since subtype parameters are PascalCase member names.
An HTTP API route whose AWS_PROXY integration has an IntegrationSubtype now
runs that AWS service action instead of resolving a Lambda function from the
integration URI. RequestParameters are mapped at invoke time: static values,
whole expressions such as $request.body, $request.body.<JSONPath>,
$request.header/querystring/path, $context and $stageVariables, and
expressions embedded as ${request.header.X}. Region selects the action's
region. A required parameter that maps to nothing answers 400
MissingParameter. The response is 200 with the action's result in the
<Action>Response/<Action>Result envelope; an action error keeps its status.
Lambda AWS_PROXY and HTTP_PROXY dispatch are unchanged.
Every subtype AWS defines is now known, with its required and optional parameters from the AWS reference, so create and update validate all of them instead of rejecting the ones Floci does not invoke. Only SQS-SendMessage carries a service action.
The subtype check is a package-private static method, and OpenAPI import and reimport run it over every x-amazon-apigateway-integration while planning, before any route or integration is deleted or created.
$request.body.<path> read a scalar through json-path as a JsonNode and threw ClassCastException, which escaped as a 500. The value is now read as an Object and converted, and resolution runs inside the dispatch error handling.
MessageAttributes and MessageSystemAttributes are parsed as JSON templates first and expressions are resolved only inside their string values, so a header holding quotes or braces stays one literal string instead of adding attributes.
Subtype parameters also resolve accountId, apiId, domainName, httpMethod, path, requestTime, requestTimeEpoch, routeKey and stage from $context. A subtype without a service action answers 500 at invoke.
UpdateIntegration keeps a field the request leaves out, so an AWS::ApiGatewayV2::Integration update that drops IntegrationSubtype kept the old one. The provisioner now clears it explicitly, records the prior subtype in the rollback snapshot and restores it when the update fails.
A number or boolean value is read as its text, and an object or array value is a 400 BadRequestException instead of an unchecked conversion error.
Adds invoke cases for $request.body.<field>, a header that tries to break out of its MessageAttributes value, and $context variables; a stored-but-not-invoked SQS-PurgeQueue integration; a reimport with an invalid subtype that leaves the API unchanged; and number and object RequestParameters values on the JSON protocol. Queue creation now sits inside the cleanup block.
A MessageAttributes or MessageSystemAttributes value that does not parse as a JSON object was interpolated as raw text, so a request value could add or change members of the attributes object. It is now an InvalidParameterValue 400; whole source expressions such as $request.body.attributes or ${request.body.attributes} still resolve as before.
- A required parameter mapped to null or a blank string is rejected like a missing one.
- A MessageAttributes or MessageSystemAttributes value must be a JSON object or a source expression.
- Number and boolean RequestParameters values sent to the REST endpoints are read as text, and object or array values are a 400 instead of a ClassCastException.
- UpdateIntegration that adds a subtype to an integration without one, and sends no PayloadFormatVersion, stores 1.0 as CreateIntegration does.
- The create, update and OpenAPI import paths share one payload format default.
- $context.requestId is the request's gateway id, honouring a valid x-amzn-RequestId override, instead of a fresh UUID.
- $context.domainName is the Host the request arrived on, falling back to the execute-api host, and $context.domainPrefix, extendedRequestId and protocol resolve.
- $context.path carries the stage prefix for a named stage, as HTTP API authorizer identity sources do.
- An integration without a Region parameter calls the service in the API's region, or the default region when the request carried none.
An x-amazon-apigateway-integration in an AWS::ApiGatewayV2::Api Body dropped integrationSubtype and requestParameters, so the API was created with a plain AWS_PROXY integration that never reached the service action. Both are now passed to CreateIntegration, which validates them as it does for every other caller. The PayloadFormatVersion default for AWS::ApiGatewayV2::Integration uses the shared helper.
The rollback snapshot restored the subtype only when the integration had one, so a failed update that added a subtype left it in place. The snapshot's subtype is now restored as recorded, null included, and a subtype change no longer marks the update as one whose other fields cannot be rolled back.
The template reader now fails on trailing tokens, so a value such as {"a":1} trailing no longer passes CreateIntegration and then has its tail dropped. The call-time check on a resolved JSON parameter uses the same reader instead of the application ObjectMapper, so create and invoke accept the same values.
A parameter value starting with $ was taken as an expression even when it named no source, such as "$5 off" or the typo $request.heder.x, so it passed CreateIntegration and resolved to nothing on every call. CreateIntegration, UpdateIntegration and OpenAPI import now answer it with a BadRequestException. The accepted sources are $request.header., $request.querystring., $request.path., $request.body and $request.body., $context. and $stageVariables., checked for a whole-value expression, each embedded ${...} expression, and the string values of a JSON parameter's object. A $ elsewhere in a value stays static text, so mixed templates are unchanged.
UpdateIntegration replaced RequestParameters wholesale, so an update that
set one optional parameter on an SQS-SendMessage integration dropped
QueueUrl and MessageBody and then failed the required-parameter check.
AWS merges: a named key is added or replaced, a key sent as an empty
string is removed, and an omitted key is kept. The merge applies to every
HTTP API integration, and the subtype check runs on the merged map.
The AWS::ApiGatewayV2::Api Body path passed requestParameters through as
objects, so an object-valued MessageAttributes was rejected as not a
string. It now reads every value with the importer's own conversion: a
number or boolean as its text, and an object or array as its JSON text.
A whitespace-only value is a valid SQS message body, and how API Gateway
treats one is unmeasured, so create now applies the same isEmpty check
invoke does instead of rejecting blank values.
ApiGatewayV2Service.stringParameters already reads number and boolean values as text and rejects object and array values, so the handler no longer converts them too.
The controller read path parameters from the decoded JAX-RS path and
substituted them into the integration URI, so a path with an encoded space
threw from URI.create and answered 500 without reaching the backend. An
encoded ? or # cut the backend path short, %2F became a separator and %252F
lost a level of encoding.
Read the target URL's path parameters from the raw request path, for REST
HTTP_PROXY, REST HTTP and HTTP API HTTP_PROXY integrations. A value mapped
from elsewhere is percent-encoded. $request.path.X and header mappings keep
the decoded value. An integration URI that cannot be parsed now answers 502.
Routes match on the decoded path, so an encoded slash ahead of a parameter
shifts the segments read off the raw path. /a%2Fb/c/d on /a/b/{proxy+} called
the backend with /backend/d. A raw value that does not decode to the decoded
parameter is now ignored, and the decoded value is encoded instead. Comparing
values rather than literal segments also covers templates with no literals,
such as /{x}/{y}/{z+} and the HTTP API route /{x}/{y+}.
* fix(apigateway): report the published regional hosted zones
A regional custom domain reported the invented Z2FDTNDATAQYL2 everywhere outside
GovCloud, so a Route 53 alias built from it pointed at a zone AWS does not have.
Vendor the data plane table of the API Gateway General Reference page into
region-facts.json, with the GovCloud guide kept as a cross-check. A region with no
row keeps the placeholder, now documented as one. Stored domains keep their id.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* test(apigateway): read the regional hosted zone through the SDK clients
Create and read the custom domains with ApiGatewayClient and ApiGatewayV2Client, so the test also shows both SDKs parse the zone fields.
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
---------
Signed-off-by: Hector Ventura <hectorvent@gmail.com>
* fix(elbv2): add X-Forwarded headers to ALB requests as AWS does
An ALB forwarded client headers unchanged, so a target never learned the
client address and trusted whatever X-Forwarded-For the client sent. The
routing.http.xff_* attributes were stored but never read.
Apply routing.http.xff_header_processing.mode and
routing.http.xff_client_port.enabled on HTTP, WebSocket and Lambda targets,
and set X-Forwarded-Proto and X-Forwarded-Port from the listener connection.
ModifyLoadBalancerAttributes now rejects invalid values for both attributes.
Keep every line of a repeated request header when proxying, and use the last
value in a Lambda event's headers map, as the ALB guide describes.
Take the HTTP API $context.identity.sourceIp from the TCP connection instead
of the caller's X-Forwarded-For, which let a caller spoof it.
* docs(apigatewayv2): limit the X-Forwarded-For hop note to ALB listeners
Retain credential choices through management, imports, copies and CloudFormation Body parsing. Carry quick-create credentials only for Lambda targets. Reconcile the accepted shared ARN classifier and CloudFormation import rollback on current main.
Signed-off-by: Andre Kurait <AndreKurait@gmail.com>
* fix(apigateway): default a REST custom domain to EDGE when no endpoint type is given
* docs(apigateway): state the CreateDomainName endpoint type default; cite its source
* test(apigateway): seed the legacy base path mapping test with a REGIONAL domain
The test reads its mappings through the v2 API, which refuses EDGE domains,
and a domain created with no endpoint type now defaults to EDGE.
* fix(apigateway): send x-amzn-ErrorType on the API key 403
* fix(apigateway): send x-amzn-ErrorType on every REST gateway response
Authorizer, validation, media-type, configuration and Lambda proxy
failures now carry the error type AWS pairs with their gateway response
type, customised or not, measured on a REST API in eu-west-1.
* fix(apigateway): keep a gateway response's own x-amzn-ErrorType where AWS does
A gateway response that maps gatewayresponse.header.x-amzn-ErrorType sends
only that value for the validation, media type, configuration and
integration types, and sends it ahead of the default for the authorizer
and API key types, as measured on AWS.
A REST API resource such as /v1/admin/catalog/{kind}/{name+} never
matched: greedy resources were matched by the literal text prefix
"/v1/admin/catalog/{kind}/", which no request path starts with, and the
template matcher skipped greedy resources. Every parameterised resource
also ranked ahead of every greedy one.
Match every resource segment by segment and rank all matches the way
AWS does: more literal segments, then more segments before the greedy
parameter, then the leftmost literal. extractPathParams now yields the
parameters before a greedy one, so {kind} reaches the proxy event,
$input.params and integration parameter mappings.
Closes#6686
* fix(cloudformation): provision a usage plan's throttle, quota and stage throttles
* fix(cloudformation): roll back a usage plan when its stack update fails
* fix(cloudformation): keep a failed usage plan update for its rollback retry
* fix(cloudformation): snapshot a usage plan under its patch lock
* fix(cloudformation): restore a usage plan without a lock-free comparison
* refactor(cloudformation): share the API key and usage plan update rollback through CfnRollback
* fix(apigateway): patch a usage plan's throttle, quota and stage throttles
* fix(apigateway): parse a usage plan stage throttle patch value as API Gateway does
* fix(apigateway): validate an UpdateUsagePlan op as API Gateway does
* test(apigateway): pin how a usage plan stage throttle patch reads numbers and rolls back
* fix(apigateway): refuse removing a usage plan method throttle path that names no method
* fix(cloudformation): keep a stage's throttle when a usage plan update leaves the stage in place
* fix(apigateway): return a usage plan's API stages, throttle and quota
* fix(apigateway): refuse a usage plan create whose text or number member is a list, map or wrong scalar
* fix(apigateway): refuse an unknown usage plan quota period before any other create check
* fix(apigateway): check a usage plan create body against API Gateway's vendored request shapes
* fix(apigateway): read a usage plan create body the way API Gateway does
* fix(apigateway): truncate a usage plan's integer limits without a double rounding
* refactor(apigateway): reuse SmithyValidationErrors and a shared request shape lookup
* fix(apigateway): answer an HTTP API proxy result without a Content-Type as text/plain
Measured on AWS (eu-west-1, 2026-10-19): an HTTP API answers a Lambda proxy
result that carries a body and no Content-Type header of its own with
text/plain; charset=utf-8, in both payload formats. Floci fell back to
application/json, the REST API's default, so a client that trusts the
header read a plain body as JSON.
The fallback now follows the API kind: an HTTP API answers text/plain, a
REST API keeps answering application/json.
Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
* test(apigateway): fold the Content-Type cases into the inference test
The three cases repeated the inference test's setup, route helper and
cleanup, so they join it: two results without a Content-Type in the two
payload formats, and one that names application/json. The docs say a
statusCode and a body, since a format 2.0 result without a statusCode
still takes the inferred JSON path, and the compatibility test's get
helper and parameterized name are back on one line each.
Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
---------
Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
* fix(apigatewayv2): answer an HTTP API's Lambda proxy body it cannot read with 500
Review of #5985: the catch at the end of buildProxyResponse still
answered an HTTP API with 502 and the function's output, for example
when isBase64Encoded is set on a body that is not base64.
Measured on HTTP APIs (eu-west-1), with payload formats 1.0 and 2.0:
API Gateway answers 500 with {"message":"Internal Server Error"} a body
that is an object or a list, an isBase64Encoded it cannot read as a
boolean, and a body said to be base64 that does not decode. It reads
isBase64Encoded's text as Go's strconv.ParseBool does: "True", "TRUE",
"t" and 1 are true, "F" and 0 false, and "tRuE", "yes", 2 and 1.5 are
not read. Floci read true, the text "true" and any integer but 0 as
true, so it relayed "True" and "t" bodies undecoded, "yes" ones as
plain text, decoded a body under 2, and answered an object body 200
with an empty body. A number or a boolean body is still its text.
The catch now answers an HTTP API with the same 500 for a result Floci
cannot parse at all; a REST API keeps its 502.
* refactor(apigatewayv2): decode an HTTP API's base64 body once
Review of #6012: the readability check decoded a base64 body that the
response then decoded again, a second decode and array for every
encoded reply. The catch at the end of buildProxyResponse already
answers an HTTP API with 500 and the generic message, so the check now
looks only at the body's shape, and a body said to be base64 that does
not decode fails where it is decoded and reaches that catch.
* fix(apigatewayv2): answer the Lambda proxy results an HTTP API cannot read with 500
Measured on HTTP APIs (eu-west-1), with payload formats 1.0 and 2.0:
a function that raises is answered 500 with {"message":"Internal Server
Error"}, not the 502 Floci sent. The same 500 answers what API Gateway
cannot read as a response: in format 1.0 a result that is not an object
with a statusCode (a result without one, a string, a number, null), and
in either format a statusCode that is not a whole number from 100 to 599
(99, 600, 201.5, "abc"); a statusCode given as text that spells one,
"201", is taken, and headers that are not an object are left out.
Format 2.0 keeps inferring a 200 for a result without a statusCode.
Floci answered a format 1.0 result without a statusCode with 200 and
its headers and body, as HttpApiLambdaProxyResponseInferenceIntegrationTest
pinned since #5153; AWS answers 500, and that test and the unit tests
that pinned 502 now expect what AWS answers. A REST API's Lambda proxy
keeps its own 502, untouched.
The HTTP API's generic error responses come from one helper, which the
invocation failures from #5935 (500, or 503 when Lambda throttles) use
too.
* test(compat): skip the HTTP API proxy cases unless the API reaches Lambda
Review of #5985: the test checked only that Lambda can be invoked, not
that API Gateway dispatches to it. It now sends a readable result through
the API first, as ApiGatewayV2ExecuteTest does, and skips the cases when
that does not come back.
* fix(apigatewayv2): apply an HTTP API's CORS configuration to its actual responses
An HTTP API with a CorsConfiguration answered the preflight from it, but the
responses of its integrations went out with no Access-Control-Allow-Origin, so
a browser refused to hand the page any answer of the API. AWS documents both
halves ("Configuring CORS for an HTTP API"): for a CORS request API Gateway
adds the configured headers to the integration's response, and once an API
has a CORS configuration it ignores the CORS headers the integration returns.
Measured on HTTP APIs (eu-west-1, 2026-10-16 and 2026-10-18):
- API Gateway's own refusals on a matched route get the same headers: a JWT
authorizer's 401 and its 403 for a missing scope, an unsigned call to an
AWS_IAM route's 403, a Lambda authorizer's 401 (no identity) and 403
(isAuthorized false); so does a function that is gone, which answers 500
Internal Server Error (Floci answered 404 "Function not found" without
them).
- A preflight a route matches (an OPTIONS or ANY route, $default) goes
through that route, its authorizer and its integration, and gets the
preflight headers on whatever answers; only a preflight no route matches
is answered 204 by API Gateway. Floci answered every preflight itself, so
a route behind an authorizer looked open to a browser's preflight.
- A preflight gets the preflight headers only when its origin, its method
and every header it asks for are allowed, and never the exposed headers;
otherwise, or for an OPTIONS without Access-Control-Request-Method, no CORS
header at all. An actual request gets them whatever its method. Lists are
joined with a bare comma.
- A preflight that gets the headers always carries
Access-Control-Allow-Headers, empty when none are configured, and
Vary: origin unless AllowOrigins is a single exact origin or "*" (two
origins, the "https://*" prefix, and "*" beside an exact origin all
vary). No other response gets a Vary; an integration's own is kept.
Floci sent no Allow-Headers when none were configured, and Vary: Origin
on every preflight that echoed the origin.
- A route without a target answers 404 Not Found with no CORS header, as an
unmatched route does (Floci answered 500).
The configuration is now applied once, by withHttpApiCors, on whatever the
matched route answers, so no response path can miss it: it drops the six
headers the configuration owns from the response and, when the Origin is
allowed (exactly, by "*", or by a prefix wildcard such as https://*), adds
Access-Control-Allow-Origin, plus Credentials and Expose-Headers when
configured, or the preflight's set for a preflight. An API without a
configuration still leaves CORS to its integrations.
Tests: ApiGatewayExecuteControllerTest for the headers withHttpApiCors
sets and when a preflight varies, HttpApiCorsIntegrationTest for the
routing, the refusals and the custom domain;
HttpApiJwtAuthorizerScopesTest and HttpApiRequestAuthorizerTest for the
measured refusals of a JWT scope and of a Lambda authorizer, on their own
fixtures; ApiGatewayV2CorsTest in sdk-test-java for the refusals, an
unmatched preflight and a two-origin API's Vary through the SDK;
ApiGatewayV2UnsignedAccountRoutingTest now tells a route found in its
account by AWS's 500 instead of Floci's "Function not found".
* fix(apigatewayv2): answer a failed invocation with API Gateway's own status and CORS headers
Review of #5935 (Qodo). Measured on an HTTP API with a CORS configuration
(eu-west-1, 2026-10-18), with an allowed Origin:
- a Lambda integration API Gateway may not invoke, and a function that
raises, answer 500 {"message":"Internal Server Error"}; a function Lambda
throttles (reserved concurrency 0) answers 503 {"message":"Service
Unavailable"}; each carries Access-Control-Allow-Origin and
Access-Control-Expose-Headers;
- an OPTIONS request no route matches is answered 204 with no CORS header
whether or not it carries Origin or Access-Control-Request-Method, so the
unmatched OPTIONS answer stays as it is, now pinned by a test.
Any AwsException from the invocation now becomes API Gateway's answer
inside the matched route, so the CORS configuration reaches it: 503 for
Lambda's throttling, 500 otherwise. Only the function that is gone did
before; the others escaped to the exception mapper without the headers.
A configured list with a null entry no longer fails a preflight: the
entry matches nothing and is left out of the header.
Tests: HttpApiCorsIntegrationTest gains a throttled function's 503 and an
unmatched OPTIONS that is not a preflight, ApiGatewayExecuteControllerTest
a null entry, and ApiGatewayV2CorsTest in sdk-test-java both new cases
through the SDK; the throttled and null cases fail on the previous head.
* test(apigatewayv2): share the HTTP_PROXY API fixture and the Lambda zip helper
Review of #5935. HttpApiCorsIntegrationTest.createProxyApi repeated the
API, stage, HTTP_PROXY integration and route sequence of
HttpApiHttpProxyMultiValueIntegrationTest.createProxyApi: both now call
HttpProxyApiFixtures.createProxyApi, which takes the API's extra fields,
the stage, the backend port and the path. The stage is auto-deployed for
both, as an API needs to be served on AWS.
The throttled function is a Node.js one built with
WebSocketTestSupport.createLambdaZip; it never runs, so its runtime does
not matter.
With TLS on, an issuer Floci serves itself, a Floci Cognito user pool for
one, presents a certificate of Floci's local CA. The JWT verifier fetched
its discovery document and JWKS with the JVM's default trust store, which
does not hold that CA, so every token of a Floci pool was refused with 401
by an HTTP API JWT authorizer (and by an AppSync OIDC provider), where the
same authorizer on a Cognito pool verifies on AWS.
FLOCI_SECURITY_ALLOW_PRIVATE_JWT_TARGETS only lets the fetch reach the
private address; the handshake still failed.
The verifier now trusts the CA bundle Floci already writes for the
containers it launches: the JVM's roots followed by Floci's own trust
anchor (the local CA, or the user's certificate file). ContainerCaBundle
gains sslContext(), an SSL context over that bundle, empty when TLS is off
or the bundle cannot be read, in which case the JVM's roots alone are
trusted as before. A readable bundle with no certificate in it is refused
the same way, since a trust store over it would trust nothing, public
issuers included. The warning for a missing bundle now also says that JWT
authorizers will refuse an issuer Floci serves.
The TLS server context of a certificate this CA issues moves from the RDS
proxy into FlociCertificateAuthority.serverSslContext, so the proxy and
the test that serves an issuer over HTTPS build it one way.
Tests: JwtSignatureVerifierTest serves an issuer over HTTPS with a
certificate Floci's CA issues, the bundle written by ContainerCaBundle and
the verifier built through its injected constructor, as in production:
refused by the JVM's roots, verified with the bundle (it fails on main).
ContainerCaBundleTest pins that the bundle's context still trusts every
JVM root and the anchor, and that an empty bundle falls back.
OidcAuthValidatorTest's mocked config now answers tls().
* fix(apigateway): refuse a long-term access key sent with a session token
AWS answers 403 "The security token included in the request is invalid"
when a long-term key comes with X-Amz-Security-Token, signed or not. The
same message without the period answers a temporary key with a wrong token.
The session token check moves to core.common.auth, and Lambda Web IamAuth
uses it too.
Closes#5858
* fix(apigateway): read the session token where the signature is and refuse an empty one
AWS ignores a token in the query of a header-signed request and a token
header on a presigned one. It refuses an empty token with any key.
* fix(apigateway): resolve imported request model references
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(apigateway): snapshot request model schemas for deployments
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(apigateway): match the default body validation error
Signed-off-by: Andre Kurait <akurait@amazon.com>
* test(apigateway): expect the AWS default validation message
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(apigateway): address model snapshot review findings
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(apigateway): resolve model URLs from deployment snapshots
Signed-off-by: Andre Kurait <akurait@amazon.com>
* test(apigateway): make model reference cases collectable
Signed-off-by: Andre Kurait <akurait@amazon.com>
* fix(apigateway): accept canonical model URLs in every partition
Signed-off-by: Andre Kurait <akurait@amazon.com>
---------
Signed-off-by: Andre Kurait <akurait@amazon.com>
* refactor(apigateway): move the v2 domain and API mapping rules into the service
CreateDomainName and CreateApiMapping on /v2/domainnames kept their rules in
ApiGatewayController: the one-configuration check, the refusal of inputs Floci
does not emulate, the flattening onto the shared custom-domain store, the API
and stage existence check, the mapping key conflict check, the API type the
mapping is routed as, and the mapping id. A CloudFormation provisioner cannot
reach a controller, so it would have had to copy them.
They now live in ApiGatewayService. createV2DomainName validates the body and
creates the domain; createApiMapping checks the API and stage, refuses a key
that is taken and routes the mapping as the API's protocol type; getApiMapping,
deleteApiMapping and apiMappingId follow. ApiGatewayService takes
ApiGatewayV2Service for the API and stage lookup, so the whole rule sits in one
place and a caller needs one service. Nothing on the v2 side depends on the v1
service, so this adds no cycle. Leaving the lookup in ApiGatewayV2Service was
tried first, but then every caller had to resolve the API before calling into
ApiGatewayService, and the rule was split across two classes again.
The code is moved, not rewritten: messages, error codes, the order of the
checks and the id scheme are unchanged, and the controller delegates.
* feat(cloudformation): provision AWS::ApiGatewayV2::DomainName and ApiMapping
Both types were left to the stub arm. A stack reported CREATE_COMPLETE, but no
domain or mapping existed, Fn::GetAtt on the domain resolved to literals such
as DomainResource.RegionalDomainName (so a Route 53 alias built from it pointed
nowhere), and with allow-stub-unsupported-resource-types off the stack rolled
back.
ApiGatewayV2DomainCfnProvisioner creates them through the v2 rules in
ApiGatewayService and injects only that service. Ref on a domain is its name
and Fn::GetAtt returns DomainNameArn, RegionalDomainName and
RegionalHostedZoneId as GetDomainName reports them. Ref on a mapping is its
ApiMappingId, which is also its only attribute.
Updates follow AWS. DomainName is the only createOnly property of either type,
and everything else changes in place: the domain's configuration is replaced as
a whole, as DomainNameConfigurations is on AWS, and a mapping's ApiId, Stage and
ApiMappingKey change without a new id. To keep the id across a key change, a
mapping now stores the apiMappingId it was given instead of deriving it from
its key on every read. A record persisted before is still read under the
derived id, and a new mapping gets the id it always had unless another mapping
holds it. Deriving the id and documenting the difference was the first version;
it was dropped because Ref changed where AWS keeps it, and the change set
already reported the key change as an update.
A replacement creates the new entity and leaves the displaced one to
ReplacementCleanup, so it is deleted in UPDATE_COMPLETE_CLEANUP_IN_PROGRESS,
kept under UpdateReplacePolicy: Retain, and put back when a later resource
fails the update. The first version deleted the old domain inside provision, as
the v1 provisioner does, and a failed rename then ended in
UPDATE_ROLLBACK_FAILED with the original domain and its mappings already gone.
A mapping moved to another domain gets an id the displaced mapping does not
hold, since two mappings under one physical id cannot be told apart, and the
domain of each displaced id is recorded beside the cleanup. An in-place update
snapshots what it changes, so a failed stack update restores it instead of
ending in UPDATE_ROLLBACK_FAILED.
CDK templates needed the v2 rules to match AWS in two more places.
apigateway.DomainName with a multi-level basePath maps a REST API through
AWS::ApiGatewayV2::ApiMapping, so a mapping now accepts a REST API stage. And
the restrictions AWS documents for API mappings are enforced, in the API and in
templates alike: no v2 call on an edge-optimized domain, with AWS's message;
TLS_1_2 for an HTTP API or a multi-level key, which also keeps such a domain on
TLS_1_2; no WebSocket API beside an HTTP or REST API; and AWS's key characters
and length.
The id-only delete accepts <ApiMappingId>|<DomainName>, the type's primary
identifier, which is how Cloud Control names a mapping; a bare id still answers
NotFoundException, so Cloud Control cannot report a delete that did not happen.
The integration test deploys two templates aws-cdk-lib 2.272.0 synthesized,
checked in with the app that produced them, and compat-cdk deploys the same
shapes.
* fix(apigateway): answer v2 domain and API mapping calls as API Gateway does
The review of this PR found four places where Floci answered differently
from API Gateway. Each was measured against API Gateway in eu-west-1 on
2026-10-04, with an imported certificate on a throwaway domain.
An HTTP API custom domain is regional. CreateDomainName and
UpdateDomainName with an endpoint type of PRIVATE, or one API Gateway does
not know, give a REGIONAL domain, where Floci refused the first and stored
the type on an update. EDGE is refused with "EDGE endpoint type is not
supported for APIGatewayV2 domainName", not the message for v2 calls on an
existing edge-optimized domain.
API mapping keys are checked as API Gateway checks them, with its messages:
a key does not end with '/', does not start with '/' or hold '//', holds
letters, digits and $-_.+!*'(), between its levels, and is at most 300
characters. No key, an empty one, or on a create one of whitespace only, is
the root; an update refuses whitespace only. Floci took "/" for the root and
had its own message for the characters, without the comma.
UpdateApiMapping and UpdateDomainName answer over the v2 HTTP API, not only
from CloudFormation. What an UpdateApiMapping leaves out keeps its value.
Cloud Control identifies an AWS::ApiGatewayV2::ApiMapping by the type's
primary identifier, <ApiMappingId>|<DomainName>, while CloudFormation's Ref
stays the bare id: CloudControlService derives the identifier from the
desired state, as it already names primary identifier fields by type, and
the provisioner deletes by it with the create-time attributes too.
* fix(apigateway): refuse a v2 update of an edge domain, and recover a compound identifier whole
The second review pass found three gaps in the previous commit.
UpdateDomainName through the v2 API converted a v1-created edge-optimized
domain to REGIONAL. The v2 API does not manage an edge-optimized domain, so
the update is refused with the message every other v2 call on one gets, and
the CloudFormation in-place update goes through the same check.
A v2 UpdateDomainName without a configuration returned the domain unchanged
without looking at the rest of the body, so a mutual TLS request was
silently dropped. ApiGatewayService.updateV2DomainName now refuses what
Floci does not emulate, and the edge-optimized domain, either way.
Cloud Control's recovery of a create that finished just before a restart
took the identifier after the last '|' of its key, which for an API
mapping's <ApiMappingId>|<DomainName> left only the domain. It now takes
everything after the key's third separator.
A later review pass found four more points.
UpdateApiMapping fills in what its body leaves out under the lock the update
takes, so two partial updates of one mapping cannot write back each other's
old values. A v2 domain's certificate is stored as the v1 API's regional
certificate, which is what a regional domain reports through both APIs; a
domain the v2 API wrote before still reports the one it holds until its
configuration is replaced. The domain ARN both APIs and both CloudFormation
provisioners build comes from ApiGatewayService.domainNameArn, the Cloud
Control test waits with the awaitSuccess helper main has since gained, and
requireMappingAllowed's javadoc is back on it.
Edge-optimized endpoints exist only in the commercial partition.
CreateRestApi and an UpdateRestApi switch of /endpointConfiguration/types
now run the same check custom domains already use, so an EDGE REST API in
China, GovCloud, ISO or EUSC is a BadRequestException. REGIONAL APIs, and
a move away from EDGE, are still accepted everywhere.
* docs(partition): document deployment, test coverage and known gaps
partitions.md said every partition-dependent rule had integration tests
over all eight partitions and that the China compat allowlist only
shrinks. Neither is accurate now: most services are tested in China
alone, and the allowlist is empty. The page now states the coverage as
it is (unit tests over every partition, IAM, Step Functions and the
cross-service smoke test through the emulator, China end to end), gives
a recipe for running a China, GovCloud, ISO or EUSC deployment, and
lists the known gaps: global state shared across partitions in one
process (now naming the Identity Center instance, which the smoke
test's inventory exempts for that reason), the commercial managed-policy
catalog, and client tooling untested outside the commercial partition.
API Gateway, IAM and Step Functions gain a Partitions section, and the
WAFv2 scope note names the partition's CloudFront region and where the
CLOUDFRONT scope exists.
* docs(partition): say only custom domains refuse EDGE, and when FLOCI_HOSTNAME is enough
The API Gateway Partitions section said EDGE was refused outside the
commercial partition and that REGIONAL and PRIVATE worked everywhere.
Only custom domains are checked: createRestApi and the REST API update
path accept EDGE in any partition, and createDomainName refuses PRIVATE
in all of them. The section now says so.
The deployment recipe offered FLOCI_HOSTNAME for a different port, but
it replaces only the host and keeps FLOCI_BASE_URL's port, so a
different port needs FLOCI_BASE_URL.
* fix(apigateway): evaluate Lambda authorizer policies with one evaluator
HTTP API (payload 1.0 and 2.0) and WebSocket $connect authorizers now
evaluate every policy statement against the execute-api ARN, instead of
reading only the first statement's Effect.
REST, HTTP and WebSocket APIs share AuthorizerPolicyEvaluator: one
validator and one set of condition keys (aws:SourceIp from the transport
address, aws:SecureTransport, aws:CurrentTime). IAM CIDR conditions now
match IPv6 ranges.
* fix(apigateway): reject malformed authorizer policy conditions
A Condition operator IAM does not know, an operator without keys, or a key
without values evaluated as a non-match or an unconditional match, so a
malformed Deny could be skipped and a malformed Allow could grant access.
Validate each operator and its values and return 500 instead. Numeric and
boolean condition values are now compared rather than dropped.
* fix(iam): leave scalar condition values to #5086
The numeric and boolean condition-value parsing moves to its own pull
request, together with the numeric and date comparison fixes it needs.
* docs: update the IAM operation count in the Service Matrix
* feat(apigatewayv2): implement UpdateVpcLink and VPC link tagging
* feat(cloudformation): provision AWS::ApiGatewayV2::VpcLink
* fix(cloudformation): keep VPC link and integration connection state on updates
* fix(cloudformation): restore the integration connection when its own update fails
* fix(apigateway): map authorizer context in HTTP integrations
HTTP backends need verified authorizer context from parameter mappings. Resolve scalar context values and replace mapped headers regardless of casing so client claims cannot remain beside verified values.
* fix(apigateway): drop unresolved context headers
Remove inbound context-mapped headers even when verified context is absent or non-scalar. Cover missing authorizer claims, forged repeated headers, OPTIONS and unresolved method mappings.
* fix(apigateway): preserve original mapping inputs
Keep HTTP proxy header, query and path mapping sources separate from outgoing destinations. Cover both mapping orders with present and missing authorizer claims through both REST execution endpoints.
* fix(apigatewayv2): allow an idempotent override-id tag on UpdateApi
A CloudFormation update resends the template's full tag set, so an
AWS::ApiGatewayV2::Api that pinned its id with floci:override-id failed
every stack update with "Reserved tag key floci:override-id can only be
supplied during resource creation" and rolled back.
UpdateApi now passes the api id to the reserved-tag guard, which already
treats an override equal to the existing id as a no-op (as TagResource
does since #3430), and stores the tags with the override keys stripped.
A different override value is still rejected.
docs/services/api-gateway.md now says a changed override is rejected on
TagResource and UpdateApi while resending the current id is accepted.
The TagResource half has been true since #3430 but was never documented.
CloudFormationIntegrationTest covers a stack update that resends the
pinned id and one that changes it.
* fix(apigatewayv2): validate UpdateApi tags before applying any field
UpdateApi set the name, description and other fields before the
reserved-tag guard ran, so a request it rejected had already changed the
stored API. A CloudFormation update that changed an api's override id
rolled back with the stack reporting UPDATE_ROLLBACK_COMPLETE while the
api kept the rejected update's description.
The guard now runs first, so a rejected update leaves the api as it was.
The CloudFormation test checks the description and tags after the
rollback.
* fix(apigateway): accept a region label before the built-in execute-api suffixes
extractApiId accepted a region label only before localhost, the configured hostname, or an AWS DNS suffix, so <apiId>.execute-api.<region>.localhost.floci.io (the shape a client derives from a stage's invoke URL) was never claimed and fell through to S3's path routes, answering NoSuchBucket for the stage segment. Accept the built-in localhost.floci.io and localhost.localstack.cloud suffixes after a region label too, for REST and HTTP APIs alike.
Closes#4701
* fix(apigateway): accept every published region label on execute-api hosts
extractApiId validated the region label with a two-letter-geo pattern, so eusc-de-east-1 was rejected before the suffix was checked and the request fell through to S3, on every tail including amazonaws.eu. Check the label against the published region ids with AwsRegions.isRegionId, the same test RegionResolver.resolveRegionFromHost applies, so the hosts the filter claims match the regions it can resolve.
* fix(apigateway): accept execute-api region labels not yet in the partition catalog
isRegionId accepts only regions in the vendored published list, so a region launched after that data was generated was rejected on its execute-api host even though signed requests accept it. Use RegionResolver.isKnownRegion, which falls back to each partition's botocore region regex; an unrecognized label such as zz-nowhere-9 is still rejected.