Skip to content

Commit 453e939

Browse files
authored
fix: use correct STS endpoint for us-iso-east-1 (#1054)
1 parent 7b940f8 commit 453e939

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/sagemaker/utils.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def get_ecr_image_uri_prefix(account, region):
536536
Returns:
537537
(str): URI prefix of ECR image
538538
"""
539-
domain = "c2s.ic.gov" if region == "us-iso-east-1" else "amazonaws.com"
539+
domain = _domain_for_region(region)
540540
return "{}.dkr.ecr.{}.{}".format(account, region, domain)
541541

542542

@@ -555,7 +555,20 @@ def sts_regional_endpoint(region):
555555
Returns:
556556
str: AWS STS regional endpoint
557557
"""
558-
return "https://sts.{}.amazonaws.com".format(region)
558+
domain = _domain_for_region(region)
559+
return "https://sts.{}.{}".format(region, domain)
560+
561+
562+
def _domain_for_region(region):
563+
"""Get the DNS suffix for the given region.
564+
565+
Args:
566+
region (str): AWS region name
567+
568+
Returns:
569+
str: the DNS suffix
570+
"""
571+
return "c2s.ic.gov" if region == "us-iso-east-1" else "amazonaws.com"
559572

560573

561574
class DeferredError(object):

tests/unit/test_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,7 @@ def test_sts_regional_endpoint():
570570
endpoint = sagemaker.utils.sts_regional_endpoint("us-west-2")
571571
assert endpoint == "https://sts.us-west-2.amazonaws.com"
572572
assert botocore.utils.is_valid_endpoint_url(endpoint)
573+
574+
endpoint = sagemaker.utils.sts_regional_endpoint("us-iso-east-1")
575+
assert endpoint == "https://sts.us-iso-east-1.c2s.ic.gov"
576+
assert botocore.utils.is_valid_endpoint_url(endpoint)

0 commit comments

Comments
 (0)