From f0783231d58e14766c58180cc314698ded26ef18 Mon Sep 17 00:00:00 2001 From: Attila Hajdrik Date: Thu, 21 Oct 2021 09:11:33 -0700 Subject: [PATCH] fix: pinpoint feature flag read (#8496) --- .../src/aws-utils/aws-pinpoint.js | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/packages/amplify-provider-awscloudformation/src/aws-utils/aws-pinpoint.js b/packages/amplify-provider-awscloudformation/src/aws-utils/aws-pinpoint.js index c72194b8c6a..08d0aed06b3 100644 --- a/packages/amplify-provider-awscloudformation/src/aws-utils/aws-pinpoint.js +++ b/packages/amplify-provider-awscloudformation/src/aws-utils/aws-pinpoint.js @@ -3,31 +3,8 @@ const { FeatureFlags } = require('amplify-cli-core'); const proxyAgent = require('proxy-agent'); const configurationManager = require('../configuration-manager'); const { formUserAgentParam } = require('./user-agent'); -const latestPinpointRegions = FeatureFlags.getNumber('latestRegionSupport.pinpoint'); const defaultPinpointRegion = 'us-east-1'; -const serviceRegionMap = { - 'us-east-1': 'us-east-1', - 'us-east-2': 'us-east-1', - 'sa-east-1': 'us-east-1', - 'ca-central-1': latestPinpointRegions >= 1 ? 'ca-central-1' : 'us-east-1', - 'us-west-1': 'us-west-2', - 'us-west-2': 'us-west-2', - 'cn-north-1': 'us-west-2', - 'cn-northwest-1': 'us-west-2', - 'ap-south-1': latestPinpointRegions >= 1 ? 'ap-south-1' : 'us-west-2', - 'ap-northeast-3': 'us-west-2', - 'ap-northeast-2': latestPinpointRegions >= 1 ? 'ap-northeast-2' : 'us-west-2', - 'ap-southeast-1': latestPinpointRegions >= 1 ? 'ap-southeast-1' : 'us-west-2', - 'ap-southeast-2': latestPinpointRegions >= 1 ? 'ap-southeast-2' : 'us-west-2', - 'ap-northeast-1': latestPinpointRegions >= 1 ? 'ap-northeast-1' : 'us-west-2', - 'eu-central-1': 'eu-central-1', - 'eu-north-1': 'eu-central-1', - 'eu-west-1': 'eu-west-1', - 'eu-west-2': latestPinpointRegions >= 1 ? 'eu-west-2' : 'eu-west-1', - 'eu-west-3': 'eu-west-1', - 'me-south-1': 'ap-south-1', -}; async function getConfiguredPinpointClient(context, category, action, envName) { let cred = {}; @@ -62,6 +39,7 @@ async function getConfiguredPinpointClient(context, category, action, envName) { } function mapServiceRegion(region) { + const serviceRegionMap = getPinpointRegionMapping(); if (serviceRegionMap[region]) { return serviceRegionMap[region]; } @@ -69,7 +47,30 @@ function mapServiceRegion(region) { } function getPinpointRegionMapping() { - return serviceRegionMap; + const latestPinpointRegions = FeatureFlags.getNumber('latestRegionSupport.pinpoint'); + + return { + 'us-east-1': 'us-east-1', + 'us-east-2': 'us-east-1', + 'sa-east-1': 'us-east-1', + 'ca-central-1': latestPinpointRegions >= 1 ? 'ca-central-1' : 'us-east-1', + 'us-west-1': 'us-west-2', + 'us-west-2': 'us-west-2', + 'cn-north-1': 'us-west-2', + 'cn-northwest-1': 'us-west-2', + 'ap-south-1': latestPinpointRegions >= 1 ? 'ap-south-1' : 'us-west-2', + 'ap-northeast-3': 'us-west-2', + 'ap-northeast-2': latestPinpointRegions >= 1 ? 'ap-northeast-2' : 'us-west-2', + 'ap-southeast-1': latestPinpointRegions >= 1 ? 'ap-southeast-1' : 'us-west-2', + 'ap-southeast-2': latestPinpointRegions >= 1 ? 'ap-southeast-2' : 'us-west-2', + 'ap-northeast-1': latestPinpointRegions >= 1 ? 'ap-northeast-1' : 'us-west-2', + 'eu-central-1': 'eu-central-1', + 'eu-north-1': 'eu-central-1', + 'eu-west-1': 'eu-west-1', + 'eu-west-2': latestPinpointRegions >= 1 ? 'eu-west-2' : 'eu-west-1', + 'eu-west-3': 'eu-west-1', + 'me-south-1': 'ap-south-1', + }; } module.exports = {