Ankur Mishra
Ankur Mishra

Reputation: 103

AWS S3 permission error when copy objects between buckets

I have written a AWS Lambda function using BOTO3 lib to copy object from one folder to another in a S3 bucket. Locally logic is working fine but post deploying to lambda, getting permission error.

S3 functions I am using in my code:

  1. boto3.resource() - to get the s3 object
  2. s3.Object() - to get the file stored in s3
  3. .get()['Body'].read() - to read content of file stored
  4. .copy(copy_source, destination_key) - to copy data from one folder to another in same S3 bucket

IAM granted permissions to lambda:

  1. "s3:PutObject"

  2. "s3:GetObject",

  3. "s3:ListBucket"

But still no luck. Can someone please tell me what other permissions do I need to grant to Lambda to access S3 for my purpose ? PS: tried looking into list of IAM actions but not able to find the missing one.

Upvotes: 0

Views: 1019

Answers (1)

jarmod
jarmod

Reputation: 78860

Your Lambda function's timeout is too low for the duration of the S3 calls you are making.

Also, there's typically no need to download an S3 object if all you want to do is copy it from S3 to S3. You are downloading the object and that is adding to your timeout woes. Simply use the client-level copy_object function.

Upvotes: 3

Related Questions