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: Use client syntax for getting file contents #1194

Merged
merged 1 commit into from
Nov 28, 2024
Merged
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
6 changes: 4 additions & 2 deletions scripts/aws/aws_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

if TYPE_CHECKING:
from mypy_boto3_s3 import S3Client
from mypy_boto3_s3.type_defs import GetObjectOutputTypeDef
else:
GetObjectOutputTypeDef = dict
S3Client = dict

S3Path = NamedTuple("S3Path", [("bucket", str), ("key", str)])
Expand All @@ -33,8 +35,8 @@ def _init_roles() -> None:
"""Load bucket to roleArn mapping for LINZ internal buckets from SSM"""
s3_client: S3Client = session.client("s3")
bucket, key = parse_path(bucket_config_path)
content_object = s3_client.Object(bucket, key)
file_content = content_object.get()["Body"].read().decode("utf-8")
content_object: GetObjectOutputTypeDef = s3_client.get_object(Bucket=bucket, Key=key)
file_content = content_object["Body"].read().decode("utf-8")
json_content = json.loads(file_content)

get_log().trace("bucket_config_load", config=bucket_config_path)
Expand Down