Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix s3 issue if deploying from region other than us-east-1 #603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/file-import-batch-job/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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():
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/layers/python-sdk/python/genai_core/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions lib/shared/layers/python-sdk/python/genai_core/presign.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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}.")
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/web-crawler-batch-job/index.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import os
import json
import boto3
from botocore.config import Config
import genai_core.utils.json
import genai_core.websites.crawler

PROCESSING_BUCKET_NAME = os.environ["INPUT_BUCKET_NAME"]
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():
Expand Down