Search code examples
amazon-web-servicesamazon-s3bucket

s3 images not loading after copying it from one bucket to another of same account


I have copied images from one bucket to another and now i am unable to access images. Error shows AccessDenied message.

I have verified file exists in bucket but unable to access it. If i remove same image and upload it again then it is working.

Please suggest any reason if anything i missed during copying bucket data from one to another.

Link which was working with old bucket and now not accessible with new bucket

https://abc.s3.amazonaws.com/uploads/profile/image/16923/client_thumb_CINDERELLA_12

Solution

  • Copy (or whatever put action) in S3 is by default private because that's the deault ACL behavior, see here. This is why you get access denied even though the source file has public access enabled. Therefore you need to specify the ACL to public-read during the copy, in your case (cli sample):

    aws s3 cp s3://mySourceBucket/test.txt s3://myDestinationBucket/test.txt --acl public-read
    

    Note that according to AWS, if you use --acl, your IAM policy must include the S3:PutObjectAcl action.

    --acl (string) Sets the ACL for the object when the command is performed. If you use this parameter you must have the "s3:PutObjectAcl" permission included in the list of actions for your IAM policy. Only accepts values of private, public-read, public-read-write, authenticated-read, aws-exec-read, bucket-owner-read, bucket-owner-full-control and log-delivery-write. See Canned ACL for details