Skip to content

Commit

Permalink
fix(region-info): ap-northeast-3 data not correctly registered
Browse files Browse the repository at this point in the history
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
  • Loading branch information
RomainMuller committed Mar 12, 2021
1 parent d3f4284 commit 53d67c3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 60 deletions.
25 changes: 13 additions & 12 deletions packages/@aws-cdk/region-info/build-tools/aws-entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down
92 changes: 44 additions & 48 deletions packages/@aws-cdk/region-info/build-tools/fact-tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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',
Expand All @@ -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',

};
18 changes: 18 additions & 0 deletions packages/@aws-cdk/region-info/build-tools/generate-static-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import {
} from './fact-tables';

async function main(): Promise<void> {
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';",
'',
Expand Down Expand Up @@ -76,6 +81,19 @@ async function main(): Promise<void> {
}
}

/**
* 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<string, unknown>) {
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);
Expand Down

0 comments on commit 53d67c3

Please sign in to comment.