Trying to read a file from a bucket in s3. The bucket has a trigger wired to a python lambda function. This then runs when a new file is put in the bucket. I keep getting an error.
This the code:
Download the file from S3 to the local filesystem
try:
s3.meta.client.download_file(bucket, key, localFilename)
except Exception as e:
print(e)
print('Error getting object {} from bucket {}. Make sure they exist and your bucket is in the same region as this function.'.format(key, bucket))
raise e
I get this error
'ClientMeta' object has no attribute 'client'
I am thinking it could be the IAM but the Lambda function has the AWSLambdaFullAccess Role which is pretty much an admin in S3.
Any help would be much appreciated
s3.metadoesn't have theclientobject, so the call above is failing before even getting to AWS. I'm guessing the exception is anAttributeError? Please edit your question to include where the variables3gets its value from. Please also include the full traceback.import boto3 # Get the service client s3 = boto3.client('s3') # Download object at bucket-name with key-name to tmp.txt s3.download_file("bucket-name", "key-name", "tmp.txt").