Skip to content

Commit

Permalink
fix(region-info): ap-northeast-3 data not correctly registered (#13564)
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

Credits to @robertd who had a draft PR with similar changes, which I
only saw once it was too late. I've retro-fitted all the good ideas they had
which I did not have on first intention - so thank you @robertd.

Co-Authored-By: @robertd 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
RomainMuller committed Mar 12, 2021
1 parent 81cf548 commit 64da84b
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 74 deletions.
53 changes: 27 additions & 26 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-2',
'ap-southeast-1',
'ap-southeast-2',
'ap-northeast-1',
'ca-central-1',
'cn-north-1',
'cn-northwest-1',
'eu-central-1',
'eu-west-1',
'eu-west-2',
'eu-west-3',
'eu-north-1',
'eu-south-1',
'me-south-1',
'sa-east-1',
'af-south-1', // Africa (Cape Town)
'ap-east-1', // Asia Pacific (Hong Kong)
'ap-northeast-1', // Asia Pacific (Tokyo)
'ap-northeast-2', // Asia Pacific (Seoul)
'ap-northeast-3', // Asia Pacific (Osaka)
'ap-south-1', // Asia Pacific (Mumbai)
'ap-southeast-1', // Asia Pacific (Singapore)
'ap-southeast-2', // Asia Pacific (Sydney)
'ca-central-1', // Canada (Central)
'cn-north-1', // China (Beijing)
'cn-northwest-1', // China (Ningxia)
'eu-central-1', // Europe (Frankfurt)
'eu-north-1', // Europe (Stockholm)
'eu-south-1', // Europe (Milan)
'eu-west-1', // Europe (Ireland)
'eu-west-2', // Europe (London)
'eu-west-3', // Europe (Paris)
'me-south-1', // Middle East (Bahrain)
'sa-east-1', // South America (São Paulo)
'us-east-1', // US East (N. Virginia)
'us-east-2', // US East (Ohio)
'us-gov-east-1', // AWS GovCloud (US-East)
'us-gov-west-1', // AWS GovCloud (US-West)
'us-iso-east-1', // AWS ISO
'us-isob-east-1', // AWS ISO-B
'us-west-1', // US West (N. California)
'us-west-2', // US West (Oregon)
].sort();

/**
Expand Down
93 changes: 45 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,63 +83,64 @@ 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-northeast-3': '840364872350',
'ap-south-1': '840364872350',
'ap-southeast-1': '840364872350',
'ap-southeast-2': '840364872350',
Expand All @@ -150,14 +151,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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ Object {
},
"vpcEndPointServiceNamePrefix": "com.amazonaws.vpce",
},
"ap-northeast-3": Object {
"cdkMetadataResourceAvailable": false,
"domainSuffix": "amazonaws.com",
"partition": "aws",
"s3StaticWebsiteEndpoint": "s3-website.ap-northeast-3.amazonaws.com",
"servicePrincipals": Object {
"application-autoscaling": "application-autoscaling.amazonaws.com",
"autoscaling": "autoscaling.amazonaws.com",
"codedeploy": "codedeploy.ap-northeast-3.amazonaws.com",
"ec2": "ec2.amazonaws.com",
"events": "events.amazonaws.com",
"lambda": "lambda.amazonaws.com",
"logs": "logs.ap-northeast-3.amazonaws.com",
"s3": "s3.amazonaws.com",
"sns": "sns.amazonaws.com",
"sqs": "sqs.amazonaws.com",
"states": "states.ap-northeast-3.amazonaws.com",
},
"vpcEndPointServiceNamePrefix": "com.amazonaws.vpce",
},
"ap-south-1": Object {
"cdkMetadataResourceAvailable": true,
"domainSuffix": "amazonaws.com",
Expand Down

0 comments on commit 64da84b

Please sign in to comment.