fix(apigateway): default a REST custom domain to EDGE when no endpoint type is given (#6885)

* 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.
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-10-28 22:08:18 -04:00
1 parent 4dbe3731a9
commit 043664471b
5 files changed
+59 -5

No files matched your search

@@ -80,6 +80,37 @@ class ApiGatewayDomainNameIntegrationTest {
deleteDomain(domain);
}
@Test
void domainWithOnlyACertificateArnDefaultsToEdge() {
String domain = "default-edge.apigw-domain-it.example.com";
createDomain("""
{"domainName":"%s","certificateArn":"%s"}
""".formatted(domain, CERTIFICATE_ARN));
given().when().get("/domainnames/" + domain).then()
.statusCode(200)
.body("endpointConfiguration.types[0]", equalTo("EDGE"))
.body("distributionDomainName", endsWith(".cloudfront.net"))
.body("distributionHostedZoneId", equalTo("Z2FDTNDATAQYW2"));
deleteDomain(domain);
}
@Test
void domainWithOnlyARegionalCertificateStaysRegional() {
String domain = "default-regional.apigw-domain-it.example.com";
createDomain("""
{"domainName":"%s","regionalCertificateArn":"%s"}
""".formatted(domain, CERTIFICATE_ARN));
given().when().get("/domainnames/" + domain).then()
.statusCode(200)
.body("endpointConfiguration.types[0]", equalTo("REGIONAL"))
.body("distributionDomainName", nullValue());
deleteDomain(domain);
}
@Test
void endpointTypeCanBeMovedFromEdgeToRegional() {
String domain = "endpoint-type.apigw-domain-it.example.com";
@@ -91,4 +91,13 @@ class ApiGatewayEdgeDomainPartitionTest {
assertEquals("BadRequestException", error.getErrorCode());
}
/** Without a type the domain is edge-optimized only where the partition has edge. */
@Test
void aDomainWithoutATypeStaysRegionalWhereThePartitionHasNoCloudFront() {
CustomDomain domain = service.createDomainName(GOV_REGION, Map.of("domainName", "default.example.com",
"certificateArn", "arn:aws-us-gov:acm:us-gov-west-1:000000000000:certificate/d"));
assertEquals("REGIONAL", domain.getEndpointConfigurationType());
}
}
@@ -41,7 +41,8 @@ class LegacyBasePathMappingIntegrationTest {
}
private void seedLegacyState() {
service.createDomainName(REGION, Map.of("domainName", DOMAIN));
// REGIONAL: the v2 mapping API this test reads through refuses an EDGE domain, as AWS does.
service.createDomainName(REGION, Map.of("domainName", DOMAIN, "endpointType", "REGIONAL"));
// The canonical root, as writes produce it today.
service.createBasePathMapping(REGION, DOMAIN, Map.of("restApiId", "api-canonical", "stage", "prod"));
// And one the old write path left under the empty key; its field still reads "(none)".