From 53d67c35e05c8bd3ee952139f24e0bbd1df2fc43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Fri, 12 Mar 2021 10:32:23 +0100 Subject: [PATCH] fix(region-info): ap-northeast-3 data not correctly registered The region information for ap-northeast-3 was not correctly registered as the region was missing from the `AWS_REGIONS` list in the `aws-entities.ts` file. This addresses the gap, and adds a validation at the beginning of `generate-static-data.ts` to ensure no "new" region is introduced here without also being introduced in the `AWS_REGIONS` list. Fixes #13561 --- .../region-info/build-tools/aws-entities.ts | 25 ++--- .../region-info/build-tools/fact-tables.ts | 92 +++++++++---------- .../build-tools/generate-static-data.ts | 18 ++++ 3 files changed, 75 insertions(+), 60 deletions(-) diff --git a/packages/@aws-cdk/region-info/build-tools/aws-entities.ts b/packages/@aws-cdk/region-info/build-tools/aws-entities.ts index 1588af66c6384..0d918cc74c314 100644 --- a/packages/@aws-cdk/region-info/build-tools/aws-entities.ts +++ b/packages/@aws-cdk/region-info/build-tools/aws-entities.ts @@ -4,32 +4,33 @@ * Not in the list ==> no built-in data for that region. */ export const AWS_REGIONS = [ - 'us-east-2', - 'us-east-1', - 'us-west-1', - 'us-west-2', - 'us-gov-east-1', - 'us-gov-west-1', - 'us-iso-east-1', - 'us-isob-east-1', 'af-south-1', 'ap-east-1', - 'ap-south-1', + 'ap-northeast-1', 'ap-northeast-2', + 'ap-northeast-3', + 'ap-south-1', 'ap-southeast-1', 'ap-southeast-2', - 'ap-northeast-1', 'ca-central-1', 'cn-north-1', 'cn-northwest-1', 'eu-central-1', + 'eu-north-1', + 'eu-south-1', 'eu-west-1', 'eu-west-2', 'eu-west-3', - 'eu-north-1', - 'eu-south-1', 'me-south-1', 'sa-east-1', + 'us-east-1', + 'us-east-2', + 'us-gov-east-1', + 'us-gov-west-1', + 'us-iso-east-1', + 'us-isob-east-1', + 'us-west-1', + 'us-west-2', ].sort(); /** diff --git a/packages/@aws-cdk/region-info/build-tools/fact-tables.ts b/packages/@aws-cdk/region-info/build-tools/fact-tables.ts index dc7f8ff586449..95d3bf6106ebe 100644 --- a/packages/@aws-cdk/region-info/build-tools/fact-tables.ts +++ b/packages/@aws-cdk/region-info/build-tools/fact-tables.ts @@ -46,29 +46,29 @@ export const AWS_CDK_METADATA = new Set([ * @see https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints */ export const ROUTE_53_BUCKET_WEBSITE_ZONE_IDS: { [region: string]: string } = { - 'us-east-2': 'Z2O1EMRO9K5GLX', - 'us-east-1': 'Z3AQBSTGFYJSTF', - 'us-west-1': 'Z2F56UZL2M1ACD', - 'us-west-2': 'Z3BJ6K6RIION7M', - 'us-gov-east-1': 'Z2NIFVYYW2VKV1', - 'us-gov-west-1': 'Z31GFT0UA1I2HV', 'af-south-1': 'Z11KHD8FBVPUYU', 'ap-east-1': 'ZNB98KWMFR0R6', - 'ap-south-1': 'Z11RGJOFQNVJUP', - 'ap-northeast-3': 'Z2YQB5RD63NC85', + 'ap-northeast-1': 'Z2M4EHUR26P7ZW', 'ap-northeast-2': 'Z3W03O7B5YMIYP', + 'ap-northeast-3': 'Z2YQB5RD63NC85', + 'ap-south-1': 'Z11RGJOFQNVJUP', 'ap-southeast-1': 'Z3O0J2DXBE1FTB', 'ap-southeast-2': 'Z1WCIGYICN2BYD', - 'ap-northeast-1': 'Z2M4EHUR26P7ZW', 'ca-central-1': 'Z1QDHH18159H29', 'eu-central-1': 'Z21DNDUVLTQW6Q', + 'eu-north-1': 'Z3BAZG2TWCNX0D', + 'eu-south-1': 'Z3IXVV8C73GIO3', 'eu-west-1': 'Z1BKCTXD74EZPE', 'eu-west-2': 'Z3GKZC51ZF0DB4', 'eu-west-3': 'Z3R1K369G5AVDG', - 'eu-north-1': 'Z3BAZG2TWCNX0D', - 'eu-south-1': 'Z3IXVV8C73GIO3', - 'sa-east-1': 'Z7KQH4QJS55SO', 'me-south-1': 'Z1MPMWCPA7YB62', + 'sa-east-1': 'Z7KQH4QJS55SO', + 'us-east-1': 'Z3AQBSTGFYJSTF', + 'us-east-2': 'Z2O1EMRO9K5GLX', + 'us-gov-east-1': 'Z2NIFVYYW2VKV1', + 'us-gov-west-1': 'Z31GFT0UA1I2HV', + 'us-west-1': 'Z2F56UZL2M1ACD', + 'us-west-2': 'Z3BJ6K6RIION7M', }; interface Region { partition: string, domainSuffix: string } @@ -83,61 +83,61 @@ export const PARTITION_MAP: { [region: string]: Region } = { // https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions export const ELBV2_ACCOUNTS: { [region: string]: string } = { - 'us-east-1': '127311923021', - 'us-east-2': '033677994240', - 'us-west-1': '027434742980', - 'us-west-2': '797873946194', 'af-south-1': '098369216593', - 'ca-central-1': '985666609251', - 'eu-central-1': '054676820928', - 'eu-west-1': '156460612806', - 'eu-west-2': '652711504416', - 'eu-west-3': '009996457667', - 'eu-south-1': '635631232127', - 'eu-north-1': '897822967062', 'ap-east-1': '754344448648', 'ap-northeast-1': '582318560864', 'ap-northeast-2': '600734575887', 'ap-northeast-3': '383597477331', + 'ap-south-1': '718504428378', 'ap-southeast-1': '114774131450', 'ap-southeast-2': '783225319266', - 'ap-south-1': '718504428378', + 'ca-central-1': '985666609251', + 'cn-north-1': '638102146993', + 'cn-northwest-1': '037604701340', + 'eu-central-1': '054676820928', + 'eu-north-1': '897822967062', + 'eu-south-1': '635631232127', + 'eu-west-1': '156460612806', + 'eu-west-2': '652711504416', + 'eu-west-3': '009996457667', 'me-south-1': '076674570225', 'sa-east-1': '507241528517', - 'us-gov-west-1': '048591011584', + 'us-east-1': '127311923021', + 'us-east-2': '033677994240', 'us-gov-east-1': '190560391635', - 'cn-north-1': '638102146993', - 'cn-northwest-1': '037604701340', + 'us-gov-west-1': '048591011584', + 'us-west-1': '027434742980', + 'us-west-2': '797873946194', }; // https://aws.amazon.com/releasenotes/available-deep-learning-containers-images export const DLC_REPOSITORY_ACCOUNTS: { [region: string]: string } = { - 'us-east-1': '763104351884', - 'us-east-2': '763104351884', - 'us-west-1': '763104351884', - 'us-west-2': '763104351884', - 'ca-central-1': '763104351884', - 'eu-west-1': '763104351884', - 'eu-west-2': '763104351884', - 'eu-west-3': '763104351884', - 'eu-central-1': '763104351884', - 'eu-north-1': '763104351884', - 'sa-east-1': '763104351884', - 'ap-south-1': '763104351884', + 'ap-east-1': '871362719292', 'ap-northeast-1': '763104351884', 'ap-northeast-2': '763104351884', + 'ap-south-1': '763104351884', 'ap-southeast-1': '763104351884', 'ap-southeast-2': '763104351884', - - 'ap-east-1': '871362719292', - 'me-south-1': '217643126080', - + 'ca-central-1': '763104351884', 'cn-north-1': '727897471807', 'cn-northwest-1': '727897471807', + 'eu-central-1': '763104351884', + 'eu-north-1': '763104351884', + 'eu-west-1': '763104351884', + 'eu-west-2': '763104351884', + 'eu-west-3': '763104351884', + 'me-south-1': '217643126080', + 'sa-east-1': '763104351884', + 'us-east-1': '763104351884', + 'us-east-2': '763104351884', + 'us-west-1': '763104351884', + 'us-west-2': '763104351884', }; // https://docs.aws.amazon.com/app-mesh/latest/userguide/envoy.html export const APPMESH_ECR_ACCOUNTS: { [region: string]: string } = { + 'af-south-1': '924023996002', + 'ap-east-1': '856666278305', 'ap-northeast-1': '840364872350', 'ap-northeast-2': '840364872350', 'ap-south-1': '840364872350', @@ -150,14 +150,10 @@ export const APPMESH_ECR_ACCOUNTS: { [region: string]: string } = { 'eu-west-1': '840364872350', 'eu-west-2': '840364872350', 'eu-west-3': '840364872350', + 'me-south-1': '772975370895', 'sa-east-1': '840364872350', 'us-east-1': '840364872350', 'us-east-2': '840364872350', 'us-west-1': '840364872350', 'us-west-2': '840364872350', - - 'me-south-1': '772975370895', - 'ap-east-1': '856666278305', - 'af-south-1': '924023996002', - }; diff --git a/packages/@aws-cdk/region-info/build-tools/generate-static-data.ts b/packages/@aws-cdk/region-info/build-tools/generate-static-data.ts index 08a9f79a72b2b..d23704b6d0062 100644 --- a/packages/@aws-cdk/region-info/build-tools/generate-static-data.ts +++ b/packages/@aws-cdk/region-info/build-tools/generate-static-data.ts @@ -8,6 +8,11 @@ import { } from './fact-tables'; async function main(): Promise { + checkRegions(APPMESH_ECR_ACCOUNTS); + checkRegions(DLC_REPOSITORY_ACCOUNTS); + checkRegions(ELBV2_ACCOUNTS); + checkRegions(ROUTE_53_BUCKET_WEBSITE_ZONE_IDS); + const lines = [ "import { Fact, FactName } from './fact';", '', @@ -76,6 +81,19 @@ async function main(): Promise { } } +/** + * Verifies that the provided map of region to fact does not contain an entry + * for a region that was not registered in `AWS_REGIONS`. + */ +function checkRegions(map: Record) { + const allRegions = new Set(AWS_REGIONS); + for (const region of Object.keys(map)) { + if (!allRegions.has(region)) { + throw new Error(`Un-registered region fact found: ${region}. Add to AWS_REGIONS list!`); + } + } +} + main().catch(e => { // eslint-disable-next-line no-console console.error(e);