Skip to content

Commit

Permalink
fix(config-resolver): resolve region first from regionHash (#2969)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Nov 1, 2021
1 parent 359c78c commit 55f4e85
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down
2 changes: 1 addition & 1 deletion packages/config-resolver/src/regionInfo/getRegionInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
42 changes: 42 additions & 0 deletions tests/functional/endpoints/fips/test_cases_supported.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
42 changes: 0 additions & 42 deletions tests/functional/endpoints/fips/test_cases_unsupported.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 55f4e85

Please sign in to comment.