diff --git a/packages/amplify-e2e-core/src/utils/test-regions.ts b/packages/amplify-e2e-core/src/utils/test-regions.ts index 29e14415bb..e940ccf014 100644 --- a/packages/amplify-e2e-core/src/utils/test-regions.ts +++ b/packages/amplify-e2e-core/src/utils/test-regions.ts @@ -3,6 +3,7 @@ import fs from 'fs-extra'; type TestRegion = { name: string; + dataAPISupported: boolean; optIn: boolean; }; @@ -14,3 +15,12 @@ export const isOptInRegion = (region: string): boolean => { return specificRegion.optIn; }; + +export const isDataAPISupported = (region: string): boolean => { + const repoRoot = path.join(__dirname, '..', '..', '..', '..'); + const supportedRegionsPath = path.join(repoRoot, 'scripts', 'e2e-test-regions.json'); + const supportedRegions: TestRegion[] = JSON.parse(fs.readFileSync(supportedRegionsPath, 'utf-8')); + const specificRegion = supportedRegions.find((testRegion) => testRegion.name == region); + + return specificRegion.dataAPISupported; +}; diff --git a/packages/amplify-graphql-api-construct-tests/src/sql-datatabase-controller.ts b/packages/amplify-graphql-api-construct-tests/src/sql-datatabase-controller.ts index 0063ac51a0..61bb96dbf5 100644 --- a/packages/amplify-graphql-api-construct-tests/src/sql-datatabase-controller.ts +++ b/packages/amplify-graphql-api-construct-tests/src/sql-datatabase-controller.ts @@ -15,6 +15,7 @@ import { storeDbConnectionConfigWithSecretsManager, deleteDBCluster, isOptInRegion, + isDataAPISupported, } from 'amplify-category-api-e2e-core'; import { SecretsManagerClient, CreateSecretCommand, DeleteSecretCommand, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager'; import { @@ -53,7 +54,7 @@ export class SqlDatatabaseController { constructor(private readonly setupQueries: Array, private readonly options: RDSConfig) { // Data API is not supported in opted-in regions - if (options.engine === 'postgres' && !isOptInRegion(options.region)) { + if (options.engine === 'postgres' && isDataAPISupported(options.region)) { this.useDataAPI = true; } else { this.useDataAPI = false; diff --git a/scripts/e2e-test-regions.json b/scripts/e2e-test-regions.json index b7273ab78e..e97590811d 100644 --- a/scripts/e2e-test-regions.json +++ b/scripts/e2e-test-regions.json @@ -1,21 +1,21 @@ [ - { "name": "ap-east-1", "optIn": true, "cognitoSupported": false, "betaLayerDeployed": true }, - { "name": "ap-northeast-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "ap-northeast-2", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "ap-south-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "ap-southeast-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "ap-southeast-2", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "ca-central-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-central-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-north-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-south-1", "optIn": true, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-west-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-west-2", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "eu-west-3", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "me-south-1", "optIn": true, "cognitoSupported": true, "betaLayerDeployed": false }, - { "name": "sa-east-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "us-east-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "us-east-2", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "us-west-1", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, - { "name": "us-west-2", "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true } + { "name": "ap-east-1", "dataAPISupported": false, "optIn": true, "cognitoSupported": false, "betaLayerDeployed": true }, + { "name": "ap-northeast-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "ap-northeast-2", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "ap-south-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "ap-southeast-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "ap-southeast-2", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "ca-central-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-central-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-north-1", "dataAPISupported": false, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-south-1", "dataAPISupported": false, "optIn": true, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-west-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-west-2", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "eu-west-3", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "me-south-1", "dataAPISupported": false, "optIn": true, "cognitoSupported": true, "betaLayerDeployed": false }, + { "name": "sa-east-1", "dataAPISupported": false, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "us-east-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "us-east-2", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "us-west-1", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true }, + { "name": "us-west-2", "dataAPISupported": true, "optIn": false, "cognitoSupported": true, "betaLayerDeployed": true } ]