Skip to content

Commit

Permalink
fix: use correct STS endpoint for us-iso-east-1 (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenyu committed Sep 20, 2019
1 parent 7b940f8 commit 453e939
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/sagemaker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def get_ecr_image_uri_prefix(account, region):
Returns:
(str): URI prefix of ECR image
"""
domain = "c2s.ic.gov" if region == "us-iso-east-1" else "amazonaws.com"
domain = _domain_for_region(region)
return "{}.dkr.ecr.{}.{}".format(account, region, domain)


Expand All @@ -555,7 +555,20 @@ def sts_regional_endpoint(region):
Returns:
str: AWS STS regional endpoint
"""
return "https://sts.{}.amazonaws.com".format(region)
domain = _domain_for_region(region)
return "https://sts.{}.{}".format(region, domain)


def _domain_for_region(region):
"""Get the DNS suffix for the given region.
Args:
region (str): AWS region name
Returns:
str: the DNS suffix
"""
return "c2s.ic.gov" if region == "us-iso-east-1" else "amazonaws.com"


class DeferredError(object):
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,3 +570,7 @@ def test_sts_regional_endpoint():
endpoint = sagemaker.utils.sts_regional_endpoint("us-west-2")
assert endpoint == "https://sts.us-west-2.amazonaws.com"
assert botocore.utils.is_valid_endpoint_url(endpoint)

endpoint = sagemaker.utils.sts_regional_endpoint("us-iso-east-1")
assert endpoint == "https://sts.us-iso-east-1.c2s.ic.gov"
assert botocore.utils.is_valid_endpoint_url(endpoint)

0 comments on commit 453e939

Please sign in to comment.