11/* eslint-disable spellcheck/spell-checker, camelcase, @typescript-eslint/no-explicit-any */
2- import { CodeBuild } from 'aws-sdk' ;
2+ import { CodeBuild , Account } from 'aws-sdk' ;
33import { config } from 'dotenv' ;
44import yargs from 'yargs' ;
55import * as aws from 'aws-sdk' ;
@@ -12,15 +12,44 @@ import { deleteS3Bucket, sleep } from '@aws-amplify/amplify-codegen-e2e-core';
1212 * Supported regions:
1313 * - All Amplify regions, as reported https://docs.aws.amazon.com/general/latest/gr/amplify.html
1414 *
15- * NOTE: The list of supported regions must be kept in sync amongst all of:
15+ * NOTE:
16+ * - The list is used to configure correct region in Amplify profile as env var $CLI_REGION
17+ * - 'ap-east-1' is not included in the list due to known discrepancy in Amplify CLI 'configure' command dropdown and supported regions
18+ *
19+ * The list of supported regions must be kept in sync amongst all of:
20+ * - Amplify CLI 'amplify configure' command regions dropdown
1621 * - the internal pipeline that publishes new lambda layer versions
22+ * - amplify-codegen/scripts/e2e-test-regions.json
1723 * - amplify-codegen/scripts/split-canary-tests.ts
1824 * - amplify-codegen/scripts/split-e2e-tests.ts
25+ * - amplify-codegen-e2e-core/src/configure/index.ts
1926 */
20- const REPO_ROOT = path . join ( __dirname , '..' , '..' , '..' ) ;
21- const SUPPORTED_REGIONS_PATH = path . join ( REPO_ROOT , 'scripts' , 'e2e-test-regions.json' ) ;
22- const AWS_REGIONS_TO_RUN_TESTS_METADATA : TestRegion [ ] = JSON . parse ( fs . readFileSync ( SUPPORTED_REGIONS_PATH , 'utf-8' ) ) ;
23- const AWS_REGIONS_TO_RUN_TESTS = AWS_REGIONS_TO_RUN_TESTS_METADATA . map ( region => region . name ) ;
27+ // const REPO_ROOT = path.join(__dirname, '..', '..', '..');
28+ // const SUPPORTED_REGIONS_PATH = path.join(REPO_ROOT, 'scripts', 'e2e-test-regions.json');
29+ // const AWS_REGIONS_TO_RUN_TESTS_METADATA: TestRegion[] = JSON.parse(fs.readFileSync(SUPPORTED_REGIONS_PATH, 'utf-8'));
30+ // const AWS_REGIONS_TO_RUN_TESTS = AWS_REGIONS_TO_RUN_TESTS_METADATA.map(region => region.name);
31+
32+ const AWS_REGIONS_TO_RUN_TESTS = [
33+ 'us-east-1' ,
34+ 'us-east-2' ,
35+ 'us-west-1' ,
36+ 'us-west-2' ,
37+ 'eu-north-1' ,
38+ 'eu-south-1' ,
39+ 'eu-west-1' ,
40+ 'eu-west-2' ,
41+ 'eu-west-3' ,
42+ 'eu-central-1' ,
43+ 'ap-northeast-1' ,
44+ 'ap-northeast-2' ,
45+ 'ap-northeast-3' ,
46+ 'ap-southeast-1' ,
47+ 'ap-southeast-2' ,
48+ 'ap-south-1' ,
49+ 'ca-central-1' ,
50+ 'me-south-1' ,
51+ 'sa-east-1' ,
52+ ] ;
2453
2554type TestRegion = {
2655 name : string ;
@@ -251,6 +280,16 @@ const getStackDetails = async (stackName: string, account: AWSAccountInfo, regio
251280 } ;
252281} ;
253282
283+ const isRegionEnabled = async ( accountInfo : AWSAccountInfo , region : string ) : Promise < boolean > => {
284+ const account = new Account ( accountInfo ) ;
285+ const optStatus = await account . getRegionOptStatus ( {
286+ RegionName : region ,
287+ AccountId : accountInfo . accountId ,
288+ } ) . promise ( ) ;
289+
290+ return optStatus . RegionOptStatus === 'ENABLED' || optStatus . RegionOptStatus === 'ENABLED_BY_DEFAULT' ;
291+ } ;
292+
254293const getStacks = async ( account : AWSAccountInfo , region : string ) : Promise < StackInfo [ ] > => {
255294 const cfnClient = new aws . CloudFormation ( getAWSConfig ( account , region ) ) ;
256295 const results : StackInfo [ ] = [ ] ;
0 commit comments