diff --git a/lib/rag-engines/data-import/functions/upload-handler/index.py b/lib/rag-engines/data-import/functions/upload-handler/index.py index 1238e1caa..f54c78bb6 100644 --- a/lib/rag-engines/data-import/functions/upload-handler/index.py +++ b/lib/rag-engines/data-import/functions/upload-handler/index.py @@ -7,12 +7,13 @@ from aws_lambda_powertools import Logger, Tracer from aws_lambda_powertools.utilities.data_classes import SQSEvent, event_source from aws_lambda_powertools.utilities.typing import LambdaContext +from botocore.config import Config logger = Logger() tracer = Tracer() sfn_client = boto3.client("stepfunctions") -s3 = boto3.client("s3") +s3 = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) FILE_IMPORT_WORKFLOW_ARN = os.environ.get("FILE_IMPORT_WORKFLOW_ARN") PROCESSING_BUCKET_NAME = os.environ.get("PROCESSING_BUCKET_NAME") diff --git a/lib/sagemaker-model/hf-custom-script-model/build-script/script.py b/lib/sagemaker-model/hf-custom-script-model/build-script/script.py index 819c3d4cd..768f4bc98 100644 --- a/lib/sagemaker-model/hf-custom-script-model/build-script/script.py +++ b/lib/sagemaker-model/hf-custom-script-model/build-script/script.py @@ -7,9 +7,10 @@ from pathlib import Path import boto3 +from botocore.config import Config from huggingface_hub import snapshot_download -s3_client = boto3.client("s3") +s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) local_model_folder = os.getenv("LOCAL_MODEL_FOLDER", "./model") bucket = os.getenv("BUILD_BUCKET", "") diff --git a/lib/shared/file-import-batch-job/main.py b/lib/shared/file-import-batch-job/main.py index 9255976a5..d92bb5cfb 100644 --- a/lib/shared/file-import-batch-job/main.py +++ b/lib/shared/file-import-batch-job/main.py @@ -1,5 +1,6 @@ import os import boto3 +from botocore.config import Config import genai_core.types import genai_core.chunks import genai_core.documents @@ -14,7 +15,7 @@ PROCESSING_BUCKET_NAME = os.environ.get("PROCESSING_BUCKET_NAME") PROCESSING_OBJECT_KEY = os.environ.get("PROCESSING_OBJECT_KEY") -s3_client = boto3.client("s3") +s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) def main(): diff --git a/lib/shared/layers/python-sdk/python/genai_core/documents.py b/lib/shared/layers/python-sdk/python/genai_core/documents.py index 81e8d679b..0ad6daafe 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/documents.py +++ b/lib/shared/layers/python-sdk/python/genai_core/documents.py @@ -3,6 +3,7 @@ import uuid from aws_lambda_powertools import Logger import boto3 +from botocore.config import Config import botocore import feedparser import genai_core.types @@ -35,7 +36,7 @@ WORKSPACE_OBJECT_TYPE = "workspace" s3 = boto3.resource("s3") -s3_client = boto3.client("s3") +s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) dynamodb = boto3.resource("dynamodb") dynamodb_client = boto3.client("dynamodb") sfn_client = boto3.client("stepfunctions") diff --git a/lib/shared/layers/python-sdk/python/genai_core/presign.py b/lib/shared/layers/python-sdk/python/genai_core/presign.py index 8930f5d17..4614bef92 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/presign.py +++ b/lib/shared/layers/python-sdk/python/genai_core/presign.py @@ -12,6 +12,7 @@ s3_client = boto3.client( "s3", + region_name = os.environ['AWS_REGION'], config=botocore.config.Config( # Presign URLs only work with CMK if sigv4 is used # (boto3 default to v2 in some cases) diff --git a/lib/shared/layers/python-sdk/python/genai_core/user_feedback.py b/lib/shared/layers/python-sdk/python/genai_core/user_feedback.py index 99cf4dfa4..6f90d0c47 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/user_feedback.py +++ b/lib/shared/layers/python-sdk/python/genai_core/user_feedback.py @@ -2,11 +2,12 @@ import uuid from aws_lambda_powertools import Logger import boto3 +from botocore.config import Config import json from datetime import datetime dynamodb = boto3.resource("dynamodb") -s3_client = boto3.client("s3") +s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) logger = Logger() USER_FEEDBACK_BUCKET_NAME = os.environ.get("USER_FEEDBACK_BUCKET_NAME") diff --git a/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_object_key.py b/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_object_key.py index e5dffcb0d..edad27cd3 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_object_key.py +++ b/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_object_key.py @@ -1,10 +1,12 @@ from aws_lambda_powertools import Logger import boto3 +from botocore.config import Config +import os logger = Logger() def delete_files_with_object_key(bucket_name, object_key): - s3_client = boto3.client("s3") + s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) s3_client.delete_object(Bucket=bucket_name, Key=object_key) logger.info(f"Deleted {object_key} from {bucket_name}.") diff --git a/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_prefix.py b/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_prefix.py index 53115fb76..098e14f34 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_prefix.py +++ b/lib/shared/layers/python-sdk/python/genai_core/utils/delete_files_with_prefix.py @@ -1,11 +1,13 @@ from aws_lambda_powertools import Logger import boto3 +from botocore.config import Config +import os logger = Logger() def delete_files_with_prefix(bucket_name, prefix): - s3_client = boto3.client("s3") + s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) continuation_token = None while True: diff --git a/lib/shared/layers/python-sdk/python/genai_core/utils/files.py b/lib/shared/layers/python-sdk/python/genai_core/utils/files.py index 7abaaeb26..f9c276921 100644 --- a/lib/shared/layers/python-sdk/python/genai_core/utils/files.py +++ b/lib/shared/layers/python-sdk/python/genai_core/utils/files.py @@ -1,6 +1,8 @@ import boto3 +from botocore.config import Config +import os -s3 = boto3.client("s3") +s3 = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) def file_exists(bucket, key): diff --git a/lib/shared/web-crawler-batch-job/index.py b/lib/shared/web-crawler-batch-job/index.py index a7a6d91dd..fefbad905 100644 --- a/lib/shared/web-crawler-batch-job/index.py +++ b/lib/shared/web-crawler-batch-job/index.py @@ -1,6 +1,7 @@ import os import json import boto3 +from botocore.config import Config import genai_core.utils.json import genai_core.websites.crawler @@ -8,7 +9,7 @@ WORKSPACE_ID = os.environ["WORKSPACE_ID"] DOCUMENT_ID = os.environ["DOCUMENT_ID"] OBJECT_KEY = os.environ["INPUT_OBJECT_KEY"] -s3_client = boto3.client("s3") +s3_client = boto3.client("s3", region_name = os.environ['AWS_REGION'], config = Config(signature_version = 's3v4')) def main():