Last active
August 30, 2023 20:22
-
-
Save tal66/ea2c78e1d163746340c8da4a0996b046 to your computer and use it in GitHub Desktop.
read s3 json in lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read json from s3 in lambda | |
s3_client = boto3.client('s3') | |
resp = s3_client.get_object( | |
Bucket='<BUCKETNAME>', | |
Key='<FILENAME>.json', | |
) | |
content = resp['Body'] # botocore.response.StreamingBody | |
json_obj = json.load(content) | |
# lambda role policy (if bucket in same account - no need to edit bucket policy) | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "Stmt", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:GetObject", | |
"s3:GetObjectAttributes" | |
], | |
"Resource": "arn:aws:s3:::<BUCKETNAME>/*" | |
} | |
] | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment