Tuesday, January 27, 2009

Setting Amazon S3 ACLs Programatically

I recently wrote a simple Python script for setting Amazon S3 ACLs. You might find it useful.

Usage:

setS3acl.py -a $AWS_ACCESS_KEY -s $AWS_SECURE_KEY -b "myBucket" -f myfile.txt -o $OWNER_AWS_ID "$USR1_AWS_ID:FULL_CONTROL" "$USR2_AWS_ID:READ"

Options

-a - your AWS access key
-s - your AWS secure access key
-b - AWS bucket name (no s3:// nor any other slashes)
-f - file name (no s3:// nor bucket prefixes, just the filename)
-o file owner (AWS ID)

Parameters:

[AWS_ID:FULL_CONTROL|READ|WRITE]

You'll need to use the AWS IDs to identify the user (the long and ugly Amazon account identifiers - e.g. a382d287d4d58222758254ddebac103f70e6f5b).

There are two Python files that you'll need:

* setS3acl.py
* S3.py

Look at the URL to find out where I store the scripts ($0.15 / GB / month) ;-)

Enjoy!

4 comments:

Pichi said...

I found storing scripts at gist.github.com much more cheaper. $0 you hardly beat. Scripts are used to be short.

Spes said...

Nice excercise, but :)
http://search.cpan.org/~mra/Net-Amazon-S3-Tools/

AWS_ACCESS_KEY_ID='xxx' AWS_ACCESS_KEY_SECRET='xxx' s3acl --set -add some@email.com:FULL_CONTROL my_bucket

Lafay Tech Plaza said...
This comment has been removed by the author.
Lafay Tech Plaza said...

TheAWS migration servicesis a very useful program. It provides users with guides and tutorials on cloud migration services. It also offers a free trial of the service for those who are interested.