Skip to content
This repository was archived by the owner on Sep 20, 2025. It is now read-only.

Commit ada733d

Browse files
committed
fix: sts missing region
1 parent 064952c commit ada733d

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/emd/models/model.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616
import boto3
1717
from .utils.text_utilities import normalize
18+
from emd.utils.aws_service_utils import get_current_region
1819
from emd.constants import (
1920
MODEL_STACK_NAME_PREFIX,
2021
MODEL_DEFAULT_TAG
@@ -374,15 +375,15 @@ def get_deploy_version_from_stack_name(cls,stack_name):
374375
raise ValueError(f"stack_name:{stack_name} is not a valid model stack name")
375376

376377
def get_image_build_account_id(self):
377-
current_account_id = boto3.client("sts").get_caller_identity()["Account"]
378+
current_account_id = boto3.client("sts", region_name=get_current_region()).get_caller_identity()["Account"]
378379
build_image_account_id = (
379380
self.executable_config.current_engine.base_image_account_id or \
380381
current_account_id
381382
)
382383
return build_image_account_id
383384

384385
def get_image_push_account_id(self):
385-
current_account_id = boto3.client("sts").get_caller_identity()["Account"]
386+
current_account_id = boto3.client("sts", region_name=get_current_region()).get_caller_identity()["Account"]
386387
return current_account_id
387388

388389
def get_image_uri(

src/emd/utils/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def inner(*args, **kwargs):
9797
@catch_aws_credential_errors
9898
def print_aws_profile():
9999
console = Console()
100-
sts = boto3.client("sts")
100+
sts = boto3.client("sts", region_name=get_current_region())
101101
response = sts.get_caller_identity()
102102
profile_name = os.environ.get("AWS_PROFILE","default")
103103
account_id = response["Account"]

src/pipeline/utils/aws_service_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import hashlib
88
import boto3
9+
from emd.utils.aws_service_utils import get_current_region
910
logger = get_logger(__name__)
1011

1112

@@ -22,7 +23,7 @@ def check_aws_environment():
2223
"""
2324
try:
2425
# Try to create a boto3 client and make a simple API call
25-
sts = boto3.client('sts')
26+
sts = boto3.client("sts", region_name=get_current_region())
2627
response = sts.get_caller_identity()
2728
logger.info("AWS environment is properly configured.")
2829
account_id = response['Account']

src/pipeline/utils/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import argparse
44
import boto3
5+
from emd.utils.aws_service_utils import get_current_region
56

67
logging.basicConfig(level=logging.INFO)
78
logger = logging.getLogger(__name__)
@@ -54,7 +55,7 @@ def download_file_from_s3_by_s5cmd(s3_file_path, local_file_path):
5455

5556
def upload_dir_to_s3(bucket_name, local_dir_name):
5657
logger.info(f"Uploading {local_dir_name} to {bucket_name} bucket")
57-
s3 = boto3.client('s3')
58+
s3 = boto3.client('s3', region_name=get_current_region())
5859
for root, dirs, files in os.walk(local_dir_name):
5960
for file in files:
6061
local_path = os.path.join(root, file)

0 commit comments

Comments
 (0)