I am new to python and following the answers from an existing_post I am trying to read a json file from amazon S3 like this:
import boto3
import os
BUCKET = 'my_bucket'
FILE_TO_READ = 'file.json'
client = boto3.client('s3',
aws_access_key_id=os.environ.my_key,
aws_secret_access_key=os.environ.my_secret_key
)
result = client.get_object(Bucket=BUCKET, Key='file')
text = result["Body"].read().decode()
print(text['key']) # Use your desired JSON Key for your value
However I am receiving the following error:
NoSuchKey: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist.
Can someone please tell me what am I doing wrong?