diff --git a/src/emd/utils/decorators.py b/src/emd/utils/decorators.py index f66b0934..0b8ede55 100644 --- a/src/emd/utils/decorators.py +++ b/src/emd/utils/decorators.py @@ -97,7 +97,7 @@ def inner(*args, **kwargs): @catch_aws_credential_errors def print_aws_profile(): console = Console() - sts = boto3.client("sts") + sts = boto3.client("sts", region_name=get_current_region()) response = sts.get_caller_identity() profile_name = os.environ.get("AWS_PROFILE","default") account_id = response["Account"] diff --git a/src/emd/utils/upload_pipeline.py b/src/emd/utils/upload_pipeline.py index c657abdf..4b5a728d 100644 --- a/src/emd/utils/upload_pipeline.py +++ b/src/emd/utils/upload_pipeline.py @@ -59,6 +59,6 @@ def upload_pipeline_source_to_s3( region ) zip_buffer = ziped_pipeline() - s3 = boto3.client('s3') + s3 = boto3.client('s3', region_name=region) s3.upload_fileobj(zip_buffer, bucket, s3_key) return f"s3://{bucket}/{s3_key}" diff --git a/src/pipeline/utils/aws_service_utils.py b/src/pipeline/utils/aws_service_utils.py index 642b9bf5..db530f46 100644 --- a/src/pipeline/utils/aws_service_utils.py +++ b/src/pipeline/utils/aws_service_utils.py @@ -6,6 +6,7 @@ import json import hashlib import boto3 +from emd.utils.aws_service_utils import get_current_region logger = get_logger(__name__) @@ -22,7 +23,7 @@ def check_aws_environment(): """ try: # Try to create a boto3 client and make a simple API call - sts = boto3.client('sts') + sts = boto3.client("sts", region_name=get_current_region()) response = sts.get_caller_identity() logger.info("AWS environment is properly configured.") account_id = response['Account'] diff --git a/src/pipeline/utils/common.py b/src/pipeline/utils/common.py index 3093f369..2b9658ca 100644 --- a/src/pipeline/utils/common.py +++ b/src/pipeline/utils/common.py @@ -2,6 +2,7 @@ import logging import argparse import boto3 +from emd.utils.aws_service_utils import get_current_region logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -54,7 +55,7 @@ def download_file_from_s3_by_s5cmd(s3_file_path, local_file_path): def upload_dir_to_s3(bucket_name, local_dir_name): logger.info(f"Uploading {local_dir_name} to {bucket_name} bucket") - s3 = boto3.client('s3') + s3 = boto3.client('s3', region_name=get_current_region()) for root, dirs, files in os.walk(local_dir_name): for file in files: local_path = os.path.join(root, file)