Skip to content

Commit aa1e14e

Browse files
committed
reverted back to orig
1 parent cb2560b commit aa1e14e

File tree

1 file changed

+2
-17
lines changed
  • aws_sra_examples/solutions/genai/bedrock_org/lambda/src

1 file changed

+2
-17
lines changed

aws_sra_examples/solutions/genai/bedrock_org/lambda/src/sra_sts.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ class SRASTS:
3333
log_level: str = os.environ.get("LOG_LEVEL", "INFO")
3434
LOGGER.setLevel(log_level)
3535

36-
def _get_partition_for_region(self, region_name: str) -> str:
37-
"""Get AWS partition for a given region.
38-
39-
Args:
40-
region_name (str): AWS region name
41-
42-
Returns:
43-
str: AWS partition name (aws, aws-cn, aws-us-gov)
44-
"""
45-
if region_name.startswith('us-gov-'):
46-
return 'aws-us-gov'
47-
elif region_name.startswith('cn-'):
48-
return 'aws-cn'
49-
return 'aws'
50-
5136
def __init__(self, profile: str = "default") -> None:
5237
"""Initialize class object.
5338
@@ -71,14 +56,14 @@ def __init__(self, profile: str = "default") -> None:
7156
self.STS_CLIENT = self.MANAGEMENT_ACCOUNT_SESSION.client("sts")
7257
self.HOME_REGION = self.MANAGEMENT_ACCOUNT_SESSION.region_name
7358
self.LOGGER.info(f"STS detected home region: {self.HOME_REGION}")
74-
self.PARTITION = self._get_partition_for_region(self.HOME_REGION)
59+
self.PARTITION = self.MANAGEMENT_ACCOUNT_SESSION.get_partition_for_region(self.HOME_REGION)
7560
except botocore.exceptions.ClientError as error:
7661
if error.response["Error"]["Code"] == "ExpiredToken":
7762
self.LOGGER.info("Token has expired, please re-run with proper credentials set.")
7863
self.MANAGEMENT_ACCOUNT_SESSION = boto3.Session()
7964
self.STS_CLIENT = self.MANAGEMENT_ACCOUNT_SESSION.client("sts")
8065
self.HOME_REGION = self.MANAGEMENT_ACCOUNT_SESSION.region_name
81-
self.PARTITION = self._get_partition_for_region(self.HOME_REGION)
66+
self.PARTITION = self.MANAGEMENT_ACCOUNT_SESSION.get_partition_for_region(self.HOME_REGION)
8267

8368
else:
8469
self.LOGGER.info(f"Error: {error}")

0 commit comments

Comments
 (0)