fix(apigateway): report the published regional hosted zones (#7487)

* 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>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-11-04 05:17:48 -04:00
1 parent 27057e2c00
commit e46579ec03
10 files changed
+298 -69

No files matched your search

+10 -6
View File
@@ -124,7 +124,8 @@ a colon in that setting. Existing stored namespaces are not migrated or deleted
ids are the same literal in every partition, as the Sign-In model spells them.
- **Hosted zones and console URLs**: load balancer and S3 website hosted zone ids come from a
per-region table (`aws/region-facts.json`, generated from the Terraform provider and the CDK,
which transcribe the AWS General Reference, and from the China and GovCloud user guides); Network
which transcribe the AWS General Reference, and from the General Reference itself and the China
and GovCloud user guides); Network
load balancers have their own zone, distinct from the Application/Classic one. The CloudFront
hosted zone is published for `aws` and `aws-cn`; the SAML sign-on URL for five partitions. The console link in a CodePipeline
approval notification uses the console host of the pipeline's partition (`console.amazonaws.cn`
@@ -132,10 +133,12 @@ a colon in that setting. Existing stored namespaces are not migrated or deleted
state it; the path after the host is the commercial console's. A generated CloudFront
distribution domain name ends in `cloudfront.cn` in China, as the China guide names the default
CloudFront domain, unless `floci.services.cloudfront.domain-suffix` is set. A regional API Gateway
custom domain reports the regional hosted zone the GovCloud guide states for `us-gov-west-1` and
`us-gov-east-1`. The ISO and EUSC regions have no load
custom domain reports the regional hosted zone the AWS General Reference publishes for its region.
The ISO and EUSC regions have no load
balancer hosted zones, and only the two ISO-F regions have an S3 website zone; where a table has
no row the field is omitted rather than guessed. An `EDGE` API Gateway REST API or custom domain is
no row the field is omitted rather than guessed. The one exception is API Gateway, whose response
always carries a zone: a region with no row reports a placeholder, listed under the open questions
below. An `EDGE` API Gateway REST API or custom domain is
refused outside the commercial partition (`BadRequestException`): GovCloud, EUSC and ISO have no
CloudFront, and China has no edge-optimized API Gateway
([China API Gateway](https://docs.amazonaws.cn/en_us/aws/latest/userguide/api-gateway.html)).
@@ -263,8 +266,9 @@ the commercial value or Floci's own base host until sourced:
- the Lambda function-URL host in the ISO and EUSC partitions (function URLs are refused in GovCloud
and China, where the partition guides list them as not available);
- whether AWS managed policy documents differ in content in China or GovCloud;
- the API Gateway regional hosted zone per region outside GovCloud: only the two GovCloud zones
are sourced, and every other region reports one placeholder zone id;
- the API Gateway regional hosted zone in the regions the General Reference does not list (China,
ISO, EUSC and `ap-southeast-6`): a custom domain there reports `Z2FDTNDATAQYL2`, a placeholder
that is no AWS zone, so a Route 53 alias built from it resolves to nothing on AWS;
- the availability-zone id prefix of the ISO and EUSC regions: zone ids there keep the whole region
(`us-iso-east-1-az1`), where the other partitions get AWS's short prefix (`use1-az1`, `usgw1-az1`,
`cnn1-az1`);
+5 -1
View File
@@ -223,7 +223,11 @@ A domain created with `CreateDomainName` is `AVAILABLE` at once. Its `regionalDo
`<domain>.regional.local`, and a request whose `Host` header is either that name or the domain
itself is routed through the domain's base path mappings to the mapped REST API stage. An
`EDGE` domain also reports a `distributionDomainName` under `cloudfront.net` and the fixed
CloudFront hosted zone `Z2FDTNDATAQYW2`; a `REGIONAL` domain reports neither, as on AWS. Moving a
CloudFront hosted zone `Z2FDTNDATAQYW2`; a `REGIONAL` domain reports neither, as on AWS. The
`regionalHostedZoneId` is the zone the [General Reference](https://docs.aws.amazon.com/general/latest/gr/apigateway.html)
publishes for the domain's region, or the placeholder `Z2FDTNDATAQYL2`, which is no AWS zone, in a
region the table does not list. The id is set at creation, so a stored domain keeps the one it
was created with. Moving a
domain between the two types with `UpdateDomainName` creates or drops the distribution. A
domain created with no endpoint type is `EDGE`, as on AWS; it is `REGIONAL` when the request
carries a regional certificate (`regionalCertificateArn` or `regionalCertificateName`) or the
@@ -13,8 +13,8 @@ import java.util.Set;
/**
* The per-region and per-partition constants AWS publishes only as prose tables, vendored in
* {@code aws/region-facts.json} by {@code tools/aws/regen_region_facts.py} from the Terraform
* provider, the CDK, the botocore models and the China and GovCloud user guides: load balancer,
* S3 website and GovCloud API Gateway hosted zone ids, the CloudFront hosted zone and distribution
* provider, the CDK, the botocore models, the API Gateway General Reference page and the China and
* GovCloud user guides: load balancer, S3 website and API Gateway regional hosted zone ids, the CloudFront hosted zone and distribution
* domain suffix per partition, the SAML sign-on URL and the management console host per partition
* and the VPC endpoint service-name prefixes. Every accessor is {@link Optional}: the ISO and EUSC partitions have no published
* hosted zones, and a service that needs one there has nothing faithful to answer.
@@ -56,7 +56,8 @@ public final class AwsRegionFacts {
/**
* The hosted zone of an API Gateway regional endpoint, which a Route 53 alias to a regional
* custom domain targets. Published in the corpus for the two GovCloud regions only.
* custom domain targets, from the General Reference table. Absent for a region with no row:
* the China, ISO and EUSC regions and {@code ap-southeast-6}.
*/
public static Optional<String> apiGatewayRegionalHostedZoneId(String region) {
return regionText(region, "apiGatewayRegionalHostedZoneId");
@@ -93,8 +93,9 @@ public class ApiGatewayService implements ResourceProvider {
private static final Set<String> EDGE_OPTIMIZED_PARTITIONS = Set.of("aws");
/**
* The regional hosted zone a custom domain reports in a region with no published one. Only
* the two GovCloud regions have a sourced zone ({@link AwsRegionFacts#apiGatewayRegionalHostedZoneId}).
* The regional hosted zone a custom domain reports in a region the General Reference does not
* list ({@link AwsRegionFacts#apiGatewayRegionalHostedZoneId}). The id is invented and is no
* AWS zone: a Route 53 alias to it resolves to nothing on AWS.
*/
private static final String UNSOURCED_REGIONAL_HOSTED_ZONE_ID = "Z2FDTNDATAQYL2"; // partition-literal: placeholder kept where no per-region source exists
+66 -32
View File
@@ -5,6 +5,7 @@
"terraform": "terraform-provider-aws internal/service/elb/hosted_zone_id_data_source.go, internal/service/elbv2/hosted_zone_id_data_source.go, internal/service/s3/hosted_zones.go, internal/conns/awsclient.go",
"cdk": "aws-cdk packages/aws-cdk-lib/region-info/build-tools/fact-tables.ts, packages/aws-cdk-lib/aws-route53-targets/lib/cloudfront-target.ts, packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts",
"docs": "aws-docs/partition-guides (snapshots of AWS guides and CLI examples) cn/cloudfront.md, cn/console.md, gov/configure-account.md, gov/govcloud-abp.md, gov/govcloud-organizations.md, rds/describe-db-instances.txt",
"apiGatewayRegionalHostedZones": "https://docs.aws.amazon.com/general/latest/gr/apigateway.html (data plane table, snapshot aws-docs/gr-apigateway.md)",
"botocore": "botocore cloudfront/2020-05-31/service-2.json (Distribution$DomainName, DistributionSummary$DomainName)",
"s3WebsiteConflicts": "terraform wins over the CDK where they disagree (it cites the S3 website-endpoint table)"
},
@@ -51,79 +52,92 @@
"albHostedZoneId": "Z268VQBMOI5EKX",
"classicElbHostedZoneId": "Z268VQBMOI5EKX",
"nlbHostedZoneId": "Z203XCE67M25HM",
"s3WebsiteHostedZoneId": "Z83WF9RJE8B12"
"s3WebsiteHostedZoneId": "Z83WF9RJE8B12",
"apiGatewayRegionalHostedZoneId": "Z2DHW2332DAMTN"
},
"ap-east-1": {
"albHostedZoneId": "Z3DQVH9N71FHZ0",
"classicElbHostedZoneId": "Z3DQVH9N71FHZ0",
"nlbHostedZoneId": "Z12Y7K3UBGUAD1",
"s3WebsiteHostedZoneId": "ZNB98KWMFR0R6"
"s3WebsiteHostedZoneId": "ZNB98KWMFR0R6",
"apiGatewayRegionalHostedZoneId": "Z3FD1VL90ND7K5"
},
"ap-east-2": {
"albHostedZoneId": "Z02789141MW7T1WBU19PO",
"classicElbHostedZoneId": "Z02789141MW7T1WBU19PO",
"nlbHostedZoneId": "Z09176273OC2HWIAUNYW",
"s3WebsiteHostedZoneId": "Z064739330DAH7WJVOO93"
"s3WebsiteHostedZoneId": "Z064739330DAH7WJVOO93",
"apiGatewayRegionalHostedZoneId": "Z02909591O7FG9Q56HWB1"
},
"ap-northeast-1": {
"albHostedZoneId": "Z14GRHDCWA56QT",
"classicElbHostedZoneId": "Z14GRHDCWA56QT",
"nlbHostedZoneId": "Z31USIVHYNEOWT",
"s3WebsiteHostedZoneId": "Z2M4EHUR26P7ZW"
"s3WebsiteHostedZoneId": "Z2M4EHUR26P7ZW",
"apiGatewayRegionalHostedZoneId": "Z1YSHQZHG15GKL"
},
"ap-northeast-2": {
"albHostedZoneId": "ZWKZPGTI48KDX",
"classicElbHostedZoneId": "ZWKZPGTI48KDX",
"nlbHostedZoneId": "ZIBE1TIR4HY56",
"s3WebsiteHostedZoneId": "Z3W03O7B5YMIYP"
"s3WebsiteHostedZoneId": "Z3W03O7B5YMIYP",
"apiGatewayRegionalHostedZoneId": "Z20JF4UZKIW1U8"
},
"ap-northeast-3": {
"albHostedZoneId": "Z5LXEXXYW11ES",
"classicElbHostedZoneId": "Z5LXEXXYW11ES",
"nlbHostedZoneId": "Z1GWIQ4HH19I5X",
"s3WebsiteHostedZoneId": "Z2YQB5RD63NC85"
"s3WebsiteHostedZoneId": "Z2YQB5RD63NC85",
"apiGatewayRegionalHostedZoneId": "Z22ILHG95FLSZ2"
},
"ap-south-1": {
"albHostedZoneId": "ZP97RAFLXTNZK",
"classicElbHostedZoneId": "ZP97RAFLXTNZK",
"nlbHostedZoneId": "ZVDDRBQ08TROA",
"s3WebsiteHostedZoneId": "Z11RGJOFQNVJUP"
"s3WebsiteHostedZoneId": "Z11RGJOFQNVJUP",
"apiGatewayRegionalHostedZoneId": "Z3VO1THU9YC4UR"
},
"ap-south-2": {
"albHostedZoneId": "Z0173938T07WNTVAEPZN",
"classicElbHostedZoneId": "Z0173938T07WNTVAEPZN",
"nlbHostedZoneId": "Z0711778386UTO08407HT",
"s3WebsiteHostedZoneId": "Z02976202B4EZMXIPMXF7"
"s3WebsiteHostedZoneId": "Z02976202B4EZMXIPMXF7",
"apiGatewayRegionalHostedZoneId": "Z0853509Q1135NJ66RUH"
},
"ap-southeast-1": {
"albHostedZoneId": "Z1LMS91P8CMLE5",
"classicElbHostedZoneId": "Z1LMS91P8CMLE5",
"nlbHostedZoneId": "ZKVM4W9LS7TM",
"s3WebsiteHostedZoneId": "Z3O0J2DXBE1FTB"
"s3WebsiteHostedZoneId": "Z3O0J2DXBE1FTB",
"apiGatewayRegionalHostedZoneId": "ZL327KTPIQFUL"
},
"ap-southeast-2": {
"albHostedZoneId": "Z1GM3OXH4ZPM65",
"classicElbHostedZoneId": "Z1GM3OXH4ZPM65",
"nlbHostedZoneId": "ZCT6FZBF4DROD",
"s3WebsiteHostedZoneId": "Z1WCIGYICN2BYD"
"s3WebsiteHostedZoneId": "Z1WCIGYICN2BYD",
"apiGatewayRegionalHostedZoneId": "Z2RPCDW04V8134"
},
"ap-southeast-3": {
"albHostedZoneId": "Z08888821HLRG5A9ZRTER",
"classicElbHostedZoneId": "Z08888821HLRG5A9ZRTER",
"nlbHostedZoneId": "Z01971771FYVNCOVWJU1G",
"s3WebsiteHostedZoneId": "Z01846753K324LI26A3VV"
"s3WebsiteHostedZoneId": "Z01846753K324LI26A3VV",
"apiGatewayRegionalHostedZoneId": "Z10132843TYUYSLUG4HA3"
},
"ap-southeast-4": {
"albHostedZoneId": "Z09517862IB2WZLPXG76F",
"classicElbHostedZoneId": "Z09517862IB2WZLPXG76F",
"nlbHostedZoneId": "Z01156963G8MIIL7X90IV",
"s3WebsiteHostedZoneId": "Z0312387243XT5FE14WFO"
"s3WebsiteHostedZoneId": "Z0312387243XT5FE14WFO",
"apiGatewayRegionalHostedZoneId": "Z092189423Y7RJK61311D"
},
"ap-southeast-5": {
"albHostedZoneId": "Z06010284QMVVW7WO5J",
"classicElbHostedZoneId": "Z06010284QMVVW7WO5J",
"nlbHostedZoneId": "Z026317210H9ACVTRO6FB",
"s3WebsiteHostedZoneId": "Z08660063OXLMA7F1FJHU"
"s3WebsiteHostedZoneId": "Z08660063OXLMA7F1FJHU",
"apiGatewayRegionalHostedZoneId": "Z0314042F0KBUTZ3X5HF"
},
"ap-southeast-6": {
"albHostedZoneId": "Z023301818UFJ50CIO0MV",
@@ -135,19 +149,22 @@
"albHostedZoneId": "Z0390008CMBRTHFGWBCB",
"classicElbHostedZoneId": "Z0390008CMBRTHFGWBCB",
"nlbHostedZoneId": "Z054363131YWATEMWRG5L",
"s3WebsiteHostedZoneId": "Z0031014GXUMRZG6I14G"
"s3WebsiteHostedZoneId": "Z0031014GXUMRZG6I14G",
"apiGatewayRegionalHostedZoneId": "Z048508712PZLK5NKG8R0"
},
"ca-central-1": {
"albHostedZoneId": "ZQSVJUPU6J1EY",
"classicElbHostedZoneId": "ZQSVJUPU6J1EY",
"nlbHostedZoneId": "Z2EPGBW3API2WT",
"s3WebsiteHostedZoneId": "Z1QDHH18159H29"
"s3WebsiteHostedZoneId": "Z1QDHH18159H29",
"apiGatewayRegionalHostedZoneId": "Z19DQILCV0OWEC"
},
"ca-west-1": {
"albHostedZoneId": "Z06473681N0SF6OS049SD",
"classicElbHostedZoneId": "Z06473681N0SF6OS049SD",
"nlbHostedZoneId": "Z02754302KBB00W2LKWZ9",
"s3WebsiteHostedZoneId": "Z03565811Z33SLEZTHOUL"
"s3WebsiteHostedZoneId": "Z03565811Z33SLEZTHOUL",
"apiGatewayRegionalHostedZoneId": "Z04745493436AWVTG1OQY"
},
"cn-north-1": {
"albHostedZoneId": "Z1GDH35T77C1KE",
@@ -282,13 +299,15 @@
"albHostedZoneId": "Z215JYRZR1TBD5",
"classicElbHostedZoneId": "Z215JYRZR1TBD5",
"nlbHostedZoneId": "Z3F0SRJ5LGBH90",
"s3WebsiteHostedZoneId": "Z21DNDUVLTQW6Q"
"s3WebsiteHostedZoneId": "Z21DNDUVLTQW6Q",
"apiGatewayRegionalHostedZoneId": "Z1U9ULNL0V5AJ3"
},
"eu-central-2": {
"albHostedZoneId": "Z06391101F2ZOEP8P5EB3",
"classicElbHostedZoneId": "Z06391101F2ZOEP8P5EB3",
"nlbHostedZoneId": "Z02239872DOALSIDCX66S",
"s3WebsiteHostedZoneId": "Z030506016YDQGETNASS"
"s3WebsiteHostedZoneId": "Z030506016YDQGETNASS",
"apiGatewayRegionalHostedZoneId": "Z09222482MK253X48U76H"
},
"eu-isoe-west-1": {
"vpcEndpointExceptionPrefix": "uk.adc-e.cloud",
@@ -303,37 +322,43 @@
"albHostedZoneId": "Z23TAZ6LKFMNIO",
"classicElbHostedZoneId": "Z23TAZ6LKFMNIO",
"nlbHostedZoneId": "Z1UDT6IFJ4EJM",
"s3WebsiteHostedZoneId": "Z3BAZG2TWCNX0D"
"s3WebsiteHostedZoneId": "Z3BAZG2TWCNX0D",
"apiGatewayRegionalHostedZoneId": "Z3UWIKFBOOGXPP"
},
"eu-south-1": {
"albHostedZoneId": "Z3ULH7SSC9OV64",
"classicElbHostedZoneId": "Z3ULH7SSC9OV64",
"nlbHostedZoneId": "Z23146JA1KNAFP",
"s3WebsiteHostedZoneId": "Z30OZKI7KPW7MI"
"s3WebsiteHostedZoneId": "Z30OZKI7KPW7MI",
"apiGatewayRegionalHostedZoneId": "Z3BT4WSQ9TDYZV"
},
"eu-south-2": {
"albHostedZoneId": "Z0956581394HF5D5LXGAP",
"classicElbHostedZoneId": "Z0956581394HF5D5LXGAP",
"nlbHostedZoneId": "Z1011216NVTVYADP1SSV",
"s3WebsiteHostedZoneId": "Z0081959F7139GRJC19J"
"s3WebsiteHostedZoneId": "Z0081959F7139GRJC19J",
"apiGatewayRegionalHostedZoneId": "Z02499852UI5HEQ5JVWX3"
},
"eu-west-1": {
"albHostedZoneId": "Z32O12XQLNTSW2",
"classicElbHostedZoneId": "Z32O12XQLNTSW2",
"nlbHostedZoneId": "Z2IFOLAFXWLO4F",
"s3WebsiteHostedZoneId": "Z1BKCTXD74EZPE"
"s3WebsiteHostedZoneId": "Z1BKCTXD74EZPE",
"apiGatewayRegionalHostedZoneId": "ZLY8HYME6SFDD"
},
"eu-west-2": {
"albHostedZoneId": "ZHURV8PSTC4K8",
"classicElbHostedZoneId": "ZHURV8PSTC4K8",
"nlbHostedZoneId": "ZD4D7Y8KGAS4G",
"s3WebsiteHostedZoneId": "Z3GKZC51ZF0DB4"
"s3WebsiteHostedZoneId": "Z3GKZC51ZF0DB4",
"apiGatewayRegionalHostedZoneId": "ZJ5UAJN8Y3Z2Q"
},
"eu-west-3": {
"albHostedZoneId": "Z3Q77PNBQS71R4",
"classicElbHostedZoneId": "Z3Q77PNBQS71R4",
"nlbHostedZoneId": "Z1CMS0P5QUZ6D5",
"s3WebsiteHostedZoneId": "Z3R1K369G5AVDG"
"s3WebsiteHostedZoneId": "Z3R1K369G5AVDG",
"apiGatewayRegionalHostedZoneId": "Z3KY65QIEKYHQQ"
},
"eusc-de-east-1": {
"vpcEndpointExceptionPrefix": "eu.amazonaws",
@@ -348,44 +373,51 @@
"albHostedZoneId": "Z09170902867EHPV2DABU",
"classicElbHostedZoneId": "Z09170902867EHPV2DABU",
"nlbHostedZoneId": "Z0313266YDI6ZRHTGQY4",
"s3WebsiteHostedZoneId": "Z09640613K4A3MN55U7GU"
"s3WebsiteHostedZoneId": "Z09640613K4A3MN55U7GU",
"apiGatewayRegionalHostedZoneId": "Z07264553HBI44N5X2CKP"
},
"me-central-1": {
"albHostedZoneId": "Z08230872XQRWHG2XF6I",
"classicElbHostedZoneId": "Z08230872XQRWHG2XF6I",
"nlbHostedZoneId": "Z00282643NTTLPANJJG2P",
"s3WebsiteHostedZoneId": "Z06143092I8HRXZRUZROF"
"s3WebsiteHostedZoneId": "Z06143092I8HRXZRUZROF",
"apiGatewayRegionalHostedZoneId": "Z08780021BKYYY8U0YHTV"
},
"me-south-1": {
"albHostedZoneId": "ZS929ML54UICD",
"classicElbHostedZoneId": "ZS929ML54UICD",
"nlbHostedZoneId": "Z3QSRYVP46NYYV",
"s3WebsiteHostedZoneId": "Z1MPMWCPA7YB62"
"s3WebsiteHostedZoneId": "Z1MPMWCPA7YB62",
"apiGatewayRegionalHostedZoneId": "Z20ZBPC0SS8806"
},
"mx-central-1": {
"albHostedZoneId": "Z023552324OKD1BB28BH5",
"classicElbHostedZoneId": "Z023552324OKD1BB28BH5",
"nlbHostedZoneId": "Z02031231H3ID6HYJ9A7U",
"s3WebsiteHostedZoneId": "Z057606446ZNVQJJ8WOP"
"s3WebsiteHostedZoneId": "Z057606446ZNVQJJ8WOP",
"apiGatewayRegionalHostedZoneId": "Z00020171WIGL5M88SHRM"
},
"sa-east-1": {
"albHostedZoneId": "Z2P70J7HTTTPLU",
"classicElbHostedZoneId": "Z2P70J7HTTTPLU",
"nlbHostedZoneId": "ZTK26PT1VY4CU",
"s3WebsiteHostedZoneId": "Z7KQH4QJS55SO"
"s3WebsiteHostedZoneId": "Z7KQH4QJS55SO",
"apiGatewayRegionalHostedZoneId": "ZCMLWB8V5SYIT"
},
"us-east-1": {
"albHostedZoneId": "Z35SXDOTRQ7X7K",
"classicElbHostedZoneId": "Z35SXDOTRQ7X7K",
"nlbHostedZoneId": "Z26RNL4JYFTOTI",
"s3WebsiteHostedZoneId": "Z3AQBSTGFYJSTF",
"apiGatewayRegionalHostedZoneId": "Z1UJRXOUMOOFQ8",
"rdsHostedZoneId": "Z2R2ITUGPM61AM"
},
"us-east-2": {
"albHostedZoneId": "Z3AADJGX6KTTL2",
"classicElbHostedZoneId": "Z3AADJGX6KTTL2",
"nlbHostedZoneId": "ZLMOA37VPKANP",
"s3WebsiteHostedZoneId": "Z2O1EMRO9K5GLX"
"s3WebsiteHostedZoneId": "Z2O1EMRO9K5GLX",
"apiGatewayRegionalHostedZoneId": "ZOJJZC49E0EPZ"
},
"us-gov-east-1": {
"albHostedZoneId": "Z166TLBEWOO7G0",
@@ -498,13 +530,15 @@
"albHostedZoneId": "Z368ELLRRE2KJ0",
"classicElbHostedZoneId": "Z368ELLRRE2KJ0",
"nlbHostedZoneId": "Z24FKFUX50B4VW",
"s3WebsiteHostedZoneId": "Z2F56UZL2M1ACD"
"s3WebsiteHostedZoneId": "Z2F56UZL2M1ACD",
"apiGatewayRegionalHostedZoneId": "Z2MUQ32089INYE"
},
"us-west-2": {
"albHostedZoneId": "Z1H1FL5HABSF5",
"classicElbHostedZoneId": "Z1H1FL5HABSF5",
"nlbHostedZoneId": "Z18D5FSROUN65G",
"s3WebsiteHostedZoneId": "Z3BJ6K6RIION7M"
"s3WebsiteHostedZoneId": "Z3BJ6K6RIION7M",
"apiGatewayRegionalHostedZoneId": "Z2OJLYMUO9EFXC"
}
}
}
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.core.common;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.Optional;
@@ -77,13 +78,27 @@ class AwsRegionFactsTest {
assertTrue(AwsRegionFacts.cloudFrontDomainSuffix(null).isEmpty());
}
/** The GovCloud guide states the two regional endpoint zones; no source covers another region. */
/** The General Reference data plane table; the GovCloud guide states the same two GovCloud zones. */
@ParameterizedTest
@CsvSource({
"us-east-1, Z1UJRXOUMOOFQ8",
"eu-west-1, ZLY8HYME6SFDD",
"ap-east-2, Z02909591O7FG9Q56HWB1",
"us-gov-west-1, Z1K6XKP9SAGWDV",
"us-gov-east-1, Z3SE9ATJYCRCZJ"})
void apiGatewayRegionalZoneFollowsTheGeneralReference(String region, String zone) {
assertEquals(Optional.of(zone), AwsRegionFacts.apiGatewayRegionalHostedZoneId(region));
}
@ParameterizedTest
@ValueSource(strings = {"ap-southeast-6", "cn-north-1", "cn-northwest-1", "eusc-de-east-1", "us-iso-east-1",
"us-isob-east-1", "eu-isoe-west-1", "us-isof-south-1"})
void apiGatewayRegionalZoneIsAbsentWhereTheTableHasNoRow(String region) {
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId(region).isEmpty());
}
@Test
void apiGatewayRegionalZoneIsPublishedForGovCloudOnly() {
assertEquals(Optional.of("Z1K6XKP9SAGWDV"), AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-gov-west-1"));
assertEquals(Optional.of("Z3SE9ATJYCRCZJ"), AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-gov-east-1"));
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId("us-east-1").isEmpty());
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId("cn-north-1").isEmpty());
void apiGatewayRegionalZoneIsAbsentWithoutARegion() {
assertTrue(AwsRegionFacts.apiGatewayRegionalHostedZoneId(null).isEmpty());
}
@@ -0,0 +1,60 @@
package io.github.hectorvent.floci.services.apigateway;
import io.github.hectorvent.floci.testing.AwsTestClients;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.apigateway.ApiGatewayClient;
import software.amazon.awssdk.services.apigateway.model.EndpointType;
import software.amazon.awssdk.services.apigatewayv2.ApiGatewayV2Client;
import software.amazon.awssdk.services.apigatewayv2.model.DomainNameConfiguration;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* The hosted zone both custom domain APIs give an SDK client for a region whose General Reference
* row is not the default region's: {@code regionalHostedZoneId} on REST, {@code hostedZoneId} on HTTP.
*/
@QuarkusTest
class ApiGatewayRegionalHostedZoneIntegrationTest {
private static final Region REGION = Region.EU_WEST_1;
private static final String ZONE = "ZLY8HYME6SFDD";
@Test
void restDomainNameReportsThePublishedZone() {
String domain = "v1.regional-zone-it.example.com";
try (ApiGatewayClient client = AwsTestClients.create(ApiGatewayClient.builder(), "000000000000", REGION)) {
try {
String created = client.createDomainName(request -> request.domainName(domain)
.endpointConfiguration(endpoint -> endpoint.types(EndpointType.REGIONAL)))
.regionalHostedZoneId();
String read = client.getDomainName(request -> request.domainName(domain)).regionalHostedZoneId();
assertEquals(ZONE, created);
assertEquals(ZONE, read);
} finally {
client.deleteDomainName(request -> request.domainName(domain));
}
}
}
@Test
void httpDomainNameReportsThePublishedZone() {
String domain = "v2.regional-zone-it.example.com";
try (ApiGatewayV2Client client = AwsTestClients.create(ApiGatewayV2Client.builder(), "000000000000", REGION)) {
try {
DomainNameConfiguration created = client.createDomainName(request -> request.domainName(domain)
.domainNameConfigurations(configuration -> configuration.endpointType("REGIONAL")))
.domainNameConfigurations().get(0);
DomainNameConfiguration read = client.getDomainName(request -> request.domainName(domain))
.domainNameConfigurations().get(0);
assertEquals(ZONE, created.hostedZoneId());
assertEquals(ZONE, read.hostedZoneId());
} finally {
client.deleteDomainName(request -> request.domainName(domain));
}
}
}
}
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.apigateway.model.CustomDomain;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.List;
import java.util.Map;
@@ -22,8 +23,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* The Route 53 hosted zone a regional custom domain reports. The GovCloud user guide states it for
* its two regions; every other region has no source and keeps the value it always reported.
* The Route 53 hosted zone a regional custom domain reports: the General Reference row for its
* region, or the invented placeholder in a region the table does not list.
*/
class ApiGatewayRegionalHostedZoneTest {
@@ -42,16 +43,23 @@ class ApiGatewayRegionalHostedZoneTest {
@ParameterizedTest
@CsvSource({
"us-east-1, Z1UJRXOUMOOFQ8",
"eu-west-1, ZLY8HYME6SFDD",
"us-gov-west-1, Z1K6XKP9SAGWDV",
"us-gov-east-1, Z3SE9ATJYCRCZJ",
"us-east-1, Z2FDTNDATAQYL2",
"cn-north-1, Z2FDTNDATAQYL2",
"eusc-de-east-1, Z2FDTNDATAQYL2"})
"us-gov-east-1, Z3SE9ATJYCRCZJ"})
void regionalDomainReportsTheRegionsPublishedZone(String region, String hostedZoneId) {
CustomDomain domain = service.createDomainName(region, Map.of(
assertEquals(hostedZoneId, createRegionalDomain(region).getRegionalHostedZoneId());
}
@ParameterizedTest
@ValueSource(strings = {"ap-southeast-6", "cn-north-1", "eusc-de-east-1", "us-iso-east-1"})
void regionalDomainReportsThePlaceholderWhereNoZoneIsPublished(String region) {
assertEquals("Z2FDTNDATAQYL2", createRegionalDomain(region).getRegionalHostedZoneId());
}
private CustomDomain createRegionalDomain(String region) {
return service.createDomainName(region, Map.of(
"domainName", "api." + region + ".example.com",
"endpointConfiguration", Map.of("types", List.of("REGIONAL"))));
assertEquals(hostedZoneId, domain.getRegionalHostedZoneId());
}
}
+45 -9
View File
@@ -38,12 +38,14 @@ China and GovCloud user guides for what neither transcribes, are the sources her
https://docs.amazonaws.cn/en_us/aws/latest/userguide/cloudfront.html -> cn/cloudfront.md, whose
Markdown rendering escapes the asterisk (`\\*.cloudfront.cn`). The other partitions have no
CloudFront.
- The Route 53 hosted zone of an API Gateway regional endpoint, for the two GovCloud regions only:
the GovCloud guide's API Gateway page (`APIGATEWAY_REGIONAL_ZONE_SENTENCE`),
- The Route 53 hosted zone of an API Gateway regional endpoint: the data plane table of the General
Reference page (`APIGATEWAY_ENDPOINT_ROW`),
https://docs.aws.amazon.com/general/latest/gr/apigateway.html -> ../gr-apigateway.md, a sibling of
the guides directory, snapshotted by the `aws-refs` skill's docs driver. A region without a row
gets no field. The GovCloud guide's API Gateway page (`APIGATEWAY_REGIONAL_ZONE_SENTENCE`),
https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-abp.html -> gov/govcloud-abp.md,
with the region
resolved through the region descriptions in `partitions.json`. No source in `local/aws` gives
the zone for any other region.
with the region resolved through the region descriptions in `partitions.json`, states the two
GovCloud zones as well; a table that disagrees with it is refused.
- The RDS hosted zone id for us-east-1 comes from the AWS CLI describe-db-instances example
(`RDS_CLI_EXAMPLE_URL` -> rds/describe-db-instances.txt).
@@ -120,6 +122,13 @@ APIGATEWAY_REGIONAL_ZONE_PARTITION = "aws-us-gov"
APIGATEWAY_REGIONAL_ZONE_SENTENCE = re.compile(
r"The Amazon Route\s53 Hosted Zone ID for the regional endpoint in the (AWS GovCloud \([A-Za-z-]+\)) Region"
r" is (Z[0-9A-Z]+)\.")
# One row per region of the data plane table, the only table on the page with `execute-api` hosts.
APIGATEWAY_ENDPOINTS_URL = "https://docs.aws.amazon.com/general/latest/gr/apigateway.html"
APIGATEWAY_ENDPOINTS_PAGE = "gr-apigateway.md"
APIGATEWAY_ENDPOINT_HOST = re.compile(r"\bexecute-api\.[a-z0-9-]+\.")
APIGATEWAY_ENDPOINT_ROW = re.compile(
r"^\|[^|\n]*\|\s*([a-z0-9-]+)\s*\|\s*execute-api\.\1\.[a-z0-9.-]+\s*\|\s*HTTPS\s*\|\s*(Z[0-9A-Z]+)\s*$",
re.MULTILINE)
RDS_ZONE_SENTENCES = {
"us-east-1": ("rds/describe-db-instances.txt", re.compile(
r'"Address":\s*"[^"\s]+\.us-east-1\.rds\.amazonaws\.com",\s*'
@@ -278,6 +287,30 @@ def parse_apigateway_regional_zones(text: str, partitions_doc: dict) -> dict[str
return zones
def parse_apigateway_endpoint_zones(text: str) -> dict[str, str]:
"""region id -> hosted zone from the General Reference data plane table. A row the pattern
cannot read is refused rather than left to look like a region AWS does not list."""
rows = APIGATEWAY_ENDPOINT_ROW.findall(text)
if not rows:
raise ValueError(f"{APIGATEWAY_ENDPOINTS_PAGE}: no data plane hosted zone row found")
hosts = len(APIGATEWAY_ENDPOINT_HOST.findall(text))
if hosts != len(rows):
raise ValueError(f"{APIGATEWAY_ENDPOINTS_PAGE}: {hosts} execute-api hosts but {len(rows)} readable rows")
zones: dict[str, str] = {}
for region, zone in rows:
if zones.setdefault(region, zone) != zone:
raise ValueError(f"{APIGATEWAY_ENDPOINTS_PAGE}: two hosted zones for {region}")
return zones
def cross_check_apigateway_zones(published: dict[str, str], govcloud: dict[str, str]) -> None:
"""The General Reference table has to state what the GovCloud guide states."""
for region, zone in sorted(govcloud.items()):
if published.get(region) != zone:
raise ValueError(f"{APIGATEWAY_ENDPOINTS_PAGE}: {region} is {published.get(region)} but "
f"{APIGATEWAY_REGIONAL_ZONE_PAGE} states {zone}")
def apigateway_zone_regions(partitions_doc: dict) -> set[str]:
"""The regions the GovCloud API Gateway page must state a regional hosted zone for."""
return {region["id"] for partition in partitions_doc["partitions"]
@@ -285,7 +318,7 @@ def apigateway_zone_regions(partitions_doc: dict) -> set[str]:
def guides_present(guides: Path) -> bool:
return all((guides / page).exists() for page in GUIDE_PAGES)
return (guides.parent / APIGATEWAY_ENDPOINTS_PAGE).exists() and all((guides / page).exists() for page in GUIDE_PAGES)
# --------------------------------------------------------------------------- #
@@ -311,8 +344,10 @@ def build(terraform: Path, cdk: Path, guides: Path, botocore_data: Path, partiti
raise ValueError("the Classic and ALB hosted-zone maps differ; the generator assumed they are one table")
console_hosts = parse_console_hosts(guides)
cloudfront_suffixes = parse_cloudfront_suffixes(botocore_data, guides)
apigateway_zones = parse_apigateway_regional_zones(
(guides / APIGATEWAY_REGIONAL_ZONE_PAGE).read_text(encoding="utf-8"), partitions_doc)
apigateway_zones = parse_apigateway_endpoint_zones(
(guides.parent / APIGATEWAY_ENDPOINTS_PAGE).read_text(encoding="utf-8"))
cross_check_apigateway_zones(apigateway_zones, parse_apigateway_regional_zones(
(guides / APIGATEWAY_REGIONAL_ZONE_PAGE).read_text(encoding="utf-8"), partitions_doc))
rds_zones = parse_guide_sentences(guides, RDS_ZONE_SENTENCES)
@@ -366,6 +401,7 @@ def build(terraform: Path, cdk: Path, guides: Path, botocore_data: Path, partiti
"terraform": f"terraform-provider-aws {TF_ELB}, {TF_ELBV2}, {TF_S3}, {TF_CLIENT}",
"cdk": f"aws-cdk {CDK_FACT_TABLES}, {CDK_CLOUDFRONT_TARGET}, {CDK_VPC_ENDPOINT}",
"docs": "aws-docs/partition-guides (snapshots of AWS guides and CLI examples) " + ", ".join(GUIDE_PAGES),
"apiGatewayRegionalHostedZones": f"{APIGATEWAY_ENDPOINTS_URL} (data plane table, snapshot aws-docs/{APIGATEWAY_ENDPOINTS_PAGE})",
"botocore": f"botocore {BOTOCORE_CLOUDFRONT} (Distribution$DomainName, DistributionSummary$DomainName)",
"s3WebsiteConflicts": "terraform wins over the CDK where they disagree (it cites the S3 website-endpoint table)",
},
@@ -488,7 +524,7 @@ def main(argv: list[str] | None = None) -> int:
print(f"{rel}: sources not checked out, shape verified only")
return 0
raise SystemExit("error: regenerating needs the terraform-provider-aws, aws-cdk and botocore checkouts "
"and the aws-docs/partition-guides snapshots under local/aws")
f"and the aws-docs/partition-guides and aws-docs/{APIGATEWAY_ENDPOINTS_PAGE} snapshots under local/aws")
document = build(args.terraform, args.cdk, args.guides, args.botocore_data,
json.loads(args.partitions.read_text(encoding="utf-8")))
+67 -1
View File
@@ -128,6 +128,35 @@ GUIDE_GOVCLOUD_APIGATEWAY = (
"The Amazon Route\u00a053 Hosted Zone ID for the regional endpoint in the AWS GovCloud (US-West) Region is"
" Z1K6XKP9SAGWDV. The Amazon Route\u00a053 Hosted Zone ID for the regional endpoint in the AWS GovCloud (US-East)"
" Region is Z3SE9ATJYCRCZJ.\n")
GENERAL_REFERENCE_APIGATEWAY = """
Amazon API Gateway control plane
| Region Name | Region | Endpoint | Protocol
| US East (N. Virginia) | us-east-1 |
apigateway.us-east-1.amazonaws.com
apigateway-fips.us-east-1.amazonaws.com
|
HTTPS
HTTPS
Amazon API Gateway data plane
| Region Name | Region | Endpoint | Protocol | Route 53 Hosted Zone ID
| US East (N. Virginia) | us-east-1 | execute-api.us-east-1.amazonaws.com | HTTPS |
Z1UJRXOUMOOFQ8
| AWS GovCloud (US-East) | us-gov-east-1 | execute-api.us-gov-east-1.amazonaws.com | HTTPS |
Z3SE9ATJYCRCZJ
| AWS GovCloud (US-West) | us-gov-west-1 | execute-api.us-gov-west-1.amazonaws.com | HTTPS |
Z1K6XKP9SAGWDV
Service quotas
"""
RDS_CLI_EXAMPLE = '''
"Endpoint": {
"Address": "mydbinstancecf.abcexample.us-east-1.rds.amazonaws.com",
@@ -164,6 +193,7 @@ def write_sources(tmp_path: Path) -> tuple[Path, Path, Path, Path]:
(guides, r.APIGATEWAY_REGIONAL_ZONE_PAGE, GUIDE_GOVCLOUD_APIGATEWAY),
(guides, r.RDS_ZONE_SENTENCES["us-east-1"][0], RDS_CLI_EXAMPLE),
(botocore, r.BOTOCORE_CLOUDFRONT, BOTOCORE_CLOUDFRONT),
(tmp_path, r.APIGATEWAY_ENDPOINTS_PAGE, GENERAL_REFERENCE_APIGATEWAY),
] + [(guides, r.CONSOLE_HOST_SENTENCES[partition][0], body) for partition, body in GUIDES.items()]:
path = root / rel
path.parent.mkdir(parents=True, exist_ok=True)
@@ -272,6 +302,39 @@ def test_api_gateway_regional_zones_resolve_the_region_by_its_description():
r.parse_apigateway_regional_zones(west_only, PARTITIONS)
def test_api_gateway_endpoint_table_reads_the_data_plane_rows_only():
assert r.parse_apigateway_endpoint_zones(GENERAL_REFERENCE_APIGATEWAY) == {
"us-east-1": "Z1UJRXOUMOOFQ8", "us-gov-east-1": "Z3SE9ATJYCRCZJ", "us-gov-west-1": "Z1K6XKP9SAGWDV"}
with pytest.raises(ValueError, match="no data plane hosted zone row"):
r.parse_apigateway_endpoint_zones("Amazon API Gateway control plane\n")
# a row that loses its zone is refused rather than read as a region AWS does not list
with pytest.raises(ValueError, match="3 execute-api hosts but 2 readable rows"):
r.parse_apigateway_endpoint_zones(GENERAL_REFERENCE_APIGATEWAY.replace("Z1UJRXOUMOOFQ8\n", "\n"))
# a host of another region in the row is not that row's zone
with pytest.raises(ValueError, match="3 execute-api hosts but 2 readable rows"):
r.parse_apigateway_endpoint_zones(GENERAL_REFERENCE_APIGATEWAY.replace(
"execute-api.us-east-1.", "execute-api.us-east-2."))
with pytest.raises(ValueError, match="two hosted zones for us-east-1"):
r.parse_apigateway_endpoint_zones(GENERAL_REFERENCE_APIGATEWAY.replace("Service quotas", """
| US East (N. Virginia) | us-east-1 | execute-api.us-east-1.amazonaws.com | HTTPS |
Z9ZZZZZZZZZZZZ
"""))
def test_build_refuses_an_endpoint_table_the_govcloud_guide_contradicts(tmp_path):
tf, cdk, guides, botocore = write_sources(tmp_path)
page = tmp_path / r.APIGATEWAY_ENDPOINTS_PAGE
page.write_text(GENERAL_REFERENCE_APIGATEWAY.replace("Z1K6XKP9SAGWDV", "Z9ZZZZZZZZZZZZ"), encoding="utf-8")
with pytest.raises(ValueError, match="us-gov-west-1 is Z9ZZZZZZZZZZZZ but gov/govcloud-abp.md states Z1K6XKP9SAGWDV"):
r.build(tf, cdk, guides, botocore, PARTITIONS)
# nor one that dropped a GovCloud row
page.write_text(GENERAL_REFERENCE_APIGATEWAY.replace(
"| AWS GovCloud (US-East) | us-gov-east-1 | execute-api.us-gov-east-1.amazonaws.com | HTTPS |\nZ3SE9ATJYCRCZJ\n",
""), encoding="utf-8")
with pytest.raises(ValueError, match="us-gov-east-1 is None"):
r.build(tf, cdk, guides, botocore, PARTITIONS)
def test_rds_example_requires_one_zone_for_the_matching_region():
page, pattern = r.RDS_ZONE_SENTENCES["us-east-1"]
assert r.parse_guide_sentence(RDS_CLI_EXAMPLE, pattern, page) == "Z2R2ITUGPM61AM"
@@ -288,6 +351,7 @@ def test_build_merges_sources_with_terraform_winning_the_s3_conflicts(tmp_path):
assert document["_source"]["rds"] == "https://docs.aws.amazon.com/cli/v1/reference/rds/describe-db-instances.html"
assert regions["us-east-1"] == {"albHostedZoneId": "Z35SXDOTRQ7X7K", "classicElbHostedZoneId": "Z35SXDOTRQ7X7K",
"nlbHostedZoneId": "Z26RNL4JYFTOTI", "s3WebsiteHostedZoneId": "Z3AQBSTGFYJSTF",
"apiGatewayRegionalHostedZoneId": "Z1UJRXOUMOOFQ8",
"rdsHostedZoneId": "Z2R2ITUGPM61AM"}
assert regions["af-south-1"]["s3WebsiteHostedZoneId"] == "Z83WF9RJE8B12"
assert regions["us-isof-south-1"] == {"s3WebsiteHostedZoneId": "Z03376072I8GXC2DXUFXI",
@@ -306,7 +370,9 @@ def test_build_merges_sources_with_terraform_winning_the_s3_conflicts(tmp_path):
"consoleHost": "console.amazonaws-us-gov.com"}
assert regions["us-gov-west-1"] == {"apiGatewayRegionalHostedZoneId": "Z1K6XKP9SAGWDV"}
assert regions["us-gov-east-1"]["apiGatewayRegionalHostedZoneId"] == "Z3SE9ATJYCRCZJ"
assert "apiGatewayRegionalHostedZoneId" not in regions["us-east-1"]
assert regions["us-east-1"]["apiGatewayRegionalHostedZoneId"] == "Z1UJRXOUMOOFQ8"
assert "apiGatewayRegionalHostedZoneId" not in regions["af-south-1"], "a region with no row stays absent"
assert document["_source"]["apiGatewayRegionalHostedZones"].startswith(r.APIGATEWAY_ENDPOINTS_URL)
assert partitions["aws-iso-f"] == {"vpcEndpointServiceNamePrefix": "gov.ic.hci.csp.vpce"}