1
  1. Let's say i have 2 aws accounts: Account1 and AccountZ
  2. I installed and configured s3cmd to have access to Account1.
  3. I created a bucket in AccountZ and made it publicly read/write
  4. I performed an s3cmd put of a text.txt from Account1 to s3://AccountZ/test.txt
  5. Then, after it uploaded, I tried to copy paste AccountZ/test.txt to a different bucket, and it says that there was an error ("The following objects were not copied due to errors from: <AccountZ folder>"). So, I tried to change the permissions to the file, and it says I dont have permissions to do that.
  6. If "upload" a file using the S3 console into AccountZ target directory, that resulting file IS copy/paste-able. So there seems to be an issue with the uploaded file due to the PUT
  7. If i change the permissions config of s3cmd to be the key/secret of AccountZ, then uploaded file's permissions work just fine and the copy/paste command is successful.

How do I upload/PUT a file to S3 so that I can then copy/paste the resulting file in the S3 console?

Kristian
  • 21,204
  • 19
  • 101
  • 176

2 Answers2

2

When an object is uploaded to S3, the owner of the object is the account that created it. In this case, the owner of the object is Account1, even though the bucket exists in AccountZ. The default permissions on the object only allow it to be modified by the owner of the object (Account1). The only thing that AccountZ will be able to do with the object is delete it.

When you create a bucket policy, that policy will automatically apply to any objects in the bucket that are 'owned' by the same account that owns the bucket. Since AccountZ owns the bucket and Account1 owns the object, the bucket policy of public read/write isn't going to apply here.

Try specifying an ACL (eg 'public-read-write') when the object is uploaded. If you need to modify an object that has already been uploaded, try the PutObjectAcl call from the S3 API using Account1's credentials. (http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectPUTacl.html)

Scott Wolf
  • 793
  • 1
  • 5
  • 7
0

In a similar strategy to what @ScottWolf proposed, I had to do the following to solve my problem:

The solution was that I had to go add a bucket policy in the source data bucket (Account1) that gave permissions to the target. then i had to re-configure my s3 api to use AccountZ's credentials and then just do a copy from Account1 to AccountZ

Kristian
  • 21,204
  • 19
  • 101
  • 176