From 55f4e855dd0ff8dd671dea6753410d042d55e8f3 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Mon, 1 Nov 2021 15:12:22 -0700 Subject: [PATCH] fix(config-resolver): resolve region first from regionHash (#2969) --- .../src/regionInfo/getRegionInfo.spec.ts | 2 +- .../src/regionInfo/getRegionInfo.ts | 2 +- .../endpoints/fips/test_cases_supported.json | 42 +++++++++++++++++++ .../fips/test_cases_unsupported.json | 42 ------------------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts b/packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts index 347fa4603c38..7ba615eecf4c 100644 --- a/packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts +++ b/packages/config-resolver/src/regionInfo/getRegionInfo.spec.ts @@ -52,7 +52,7 @@ describe(getRegionInfo.name, () => { }); const getMockResolvedRegion = (regionCase: RegionCase): string => - regionCase === RegionCase.REGION ? mockRegion : mockEndpointRegion; + regionCase !== RegionCase.ENDPOINT ? mockRegion : mockEndpointRegion; const getMockResolvedPartitionOptions = (partitionHash) => ({ partitionHash }); diff --git a/packages/config-resolver/src/regionInfo/getRegionInfo.ts b/packages/config-resolver/src/regionInfo/getRegionInfo.ts index c4ec84ef3e9e..aa47268a04c7 100644 --- a/packages/config-resolver/src/regionInfo/getRegionInfo.ts +++ b/packages/config-resolver/src/regionInfo/getRegionInfo.ts @@ -17,7 +17,7 @@ export const getRegionInfo = ( { signingService, regionHash, partitionHash }: GetRegionInfoOptions ): RegionInfo => { const partition = getResolvedPartition(region, { partitionHash }); - const resolvedRegion = partitionHash[partition]?.endpoint ?? region; + const resolvedRegion = region in regionHash ? region : partitionHash[partition]?.endpoint ?? region; const hostname = getResolvedHostname(resolvedRegion, { signingService, diff --git a/tests/functional/endpoints/fips/test_cases_supported.json b/tests/functional/endpoints/fips/test_cases_supported.json index af6b2608f785..fd7c134e53d0 100644 --- a/tests/functional/endpoints/fips/test_cases_supported.json +++ b/tests/functional/endpoints/fips/test_cases_supported.json @@ -1553,6 +1553,13 @@ "signingRegion": "us-east-2", "hostname": "health-fips.us-east-2.amazonaws.com" }, + { + "endpointPrefix": "iam", + "sdkId": "IAM", + "region": "iam-fips", + "signingRegion": "us-east-1", + "hostname": "iam-fips.amazonaws.com" + }, { "endpointPrefix": "identity-chime", "sdkId": "Chime SDK Identity", @@ -1959,6 +1966,13 @@ "signingRegion": "us-west-2", "hostname": "network-firewall-fips.us-west-2.amazonaws.com" }, + { + "endpointPrefix": "organizations", + "sdkId": "Organizations", + "region": "fips-aws-global", + "signingRegion": "us-east-1", + "hostname": "organizations-fips.us-east-1.amazonaws.com" + }, { "endpointPrefix": "outposts", "sdkId": "Outposts", @@ -2155,6 +2169,13 @@ "signingRegion": "us-west-2", "hostname": "resource-groups-fips.us-west-2.amazonaws.com" }, + { + "endpointPrefix": "route53", + "sdkId": "Route 53", + "region": "fips-aws-global", + "signingRegion": "us-east-1", + "hostname": "route53-fips.amazonaws.com" + }, { "endpointPrefix": "runtime.lex", "sdkId": "Lex Runtime Service", @@ -2372,6 +2393,13 @@ "signingRegion": "us-west-2", "hostname": "session.qldb-fips.us-west-2.amazonaws.com" }, + { + "endpointPrefix": "shield", + "sdkId": "Shield", + "region": "fips-aws-global", + "signingRegion": "us-east-1", + "hostname": "shield-fips.us-east-1.amazonaws.com" + }, { "endpointPrefix": "sms", "sdkId": "SMS", @@ -2841,6 +2869,13 @@ "signingRegion": "us-west-2", "hostname": "translate-fips.us-west-2.amazonaws.com" }, + { + "endpointPrefix": "waf", + "sdkId": "WAF", + "region": "aws-fips", + "signingRegion": "us-east-1", + "hostname": "waf-fips.amazonaws.com" + }, { "endpointPrefix": "waf-regional", "sdkId": "WAF Regional", @@ -3730,6 +3765,13 @@ "signingRegion": "us-gov-west-1", "hostname": "servicecatalog-appregistry.us-gov-west-1.amazonaws.com" }, + { + "endpointPrefix": "servicediscovery", + "sdkId": "ServiceDiscovery", + "region": "servicediscovery-fips", + "signingRegion": "us-gov-west-1", + "hostname": "servicediscovery-fips.us-gov-west-1.amazonaws.com" + }, { "endpointPrefix": "servicequotas", "sdkId": "Service Quotas", diff --git a/tests/functional/endpoints/fips/test_cases_unsupported.json b/tests/functional/endpoints/fips/test_cases_unsupported.json index d1c07075d7bc..1d6bbd4f33ba 100644 --- a/tests/functional/endpoints/fips/test_cases_unsupported.json +++ b/tests/functional/endpoints/fips/test_cases_unsupported.json @@ -27,48 +27,6 @@ "signingRegion": "us-isob-east-1", "hostname": "dms.us-isob-east-1.sc2s.sgov.gov" }, - { - "endpointPrefix": "waf", - "sdkId": "WAF", - "region": "aws-fips", - "signingRegion": "us-east-1", - "hostname": "waf-fips.amazonaws.com" - }, - { - "endpointPrefix": "iam", - "sdkId": "IAM", - "region": "iam-fips", - "signingRegion": "us-east-1", - "hostname": "iam-fips.amazonaws.com" - }, - { - "endpointPrefix": "organizations", - "sdkId": "Organizations", - "region": "fips-aws-global", - "signingRegion": "us-east-1", - "hostname": "organizations-fips.us-east-1.amazonaws.com" - }, - { - "endpointPrefix": "route53", - "sdkId": "Route 53", - "region": "fips-aws-global", - "signingRegion": "us-east-1", - "hostname": "route53-fips.amazonaws.com" - }, - { - "endpointPrefix": "shield", - "sdkId": "Shield", - "region": "fips-aws-global", - "signingRegion": "us-east-1", - "hostname": "shield-fips.us-east-1.amazonaws.com" - }, - { - "endpointPrefix": "servicediscovery", - "sdkId": "ServiceDiscovery", - "region": "servicediscovery-fips", - "signingRegion": "us-gov-west-1", - "hostname": "servicediscovery-fips.us-gov-west-1.amazonaws.com" - }, { "endpointPrefix": "servicediscovery", "sdkId": "ServiceDiscovery",