Custom ACL for S3 buckets and keys.

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Virtualization and Cloud Computing Custom ACL for S3 buckets and keys.
# 1  
Old 12-23-2009
Custom ACL for S3 buckets and keys.

Recently I realized that s3cmd (ubuntu) does not let you have custom acl's on s3 objects. So I wrote the following ruby script and I thought I could share with you all. Using s3fox, s3hub etc was really painful.

Code:
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'

key = ARGV[0] ## they key that you want to add ACL to. e.g. foo.txt
bucket = "<your_bucket_name>"
user_id = "<id_of_theobject>" ## It is a little tricky to get this one.
name = "<display_name_of_the_user>"
perms = "<Permissions you want in the ACL>" ## e.g. READ

AWS::S3::Base.establish_connection!(
  :access_key_id     => "<key_id>",
  :secret_access_key => "<access_key>"
)

policy = AWS::S3::S3Object.acl( key, bucket )
grant = AWS::S3::ACL::Grant.new
grantee = AWS::S3::ACL::Grantee.new
grant.grantee = grantee
grant.permission = perms
policy.grants << grant
grantee.type = "CanonicalUser"
grantee.id = user_id
grantee.display_name = name
AWS::S3::S3Object.acl( key, bucket , policy)

## And thats it, run s3cmd info /<BUCKET>/<key> to see the new ACL.


Last edited by Scott; 12-23-2009 at 11:08 PM.. Reason: sharing code tags :)
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

ACL on the Solaris

we have two Solaris 10 servers with same configuration and settings. We have hard mounted the NFS with the version 4. In one of the server the newer ACL commands are working fine (chmod and ls -v) whereas in another only posix (getfacl and setfacl alone is working) when we try ls -V in in that... (13 Replies)
Discussion started by: sathishbabu89
13 Replies

2. UNIX for Dummies Questions & Answers

ACL concept

Hi.. Could someone explain about setfacl,getfacl in unix and its uses. Regards, Suresh (1 Reply)
Discussion started by: suresh sunkara
1 Replies

3. UNIX for Advanced & Expert Users

Need assistance on ACL

Hi Friends, I went through the ACL threads that were posted in the past but none were matching to my requirement . Hence starting a new thread . Challenge : user : a group : Test1 user: b group: Test2 Say under user a i create dir /tmp/debug with the privilege of 755 and also... (3 Replies)
Discussion started by: leobreaker
3 Replies

4. Solaris

ACL

Can i get the synopsis for add multiple users in single command for ACL access for a directory or a file thanks in advance dinu (3 Replies)
Discussion started by: dinu
3 Replies

5. Shell Programming and Scripting

What are public keys in ssh and how do we create the public keys??

Hi All, I am having knowledge on some basics of ssh and wanted to know what are the public keys and how can we create and implement it in connecting server. Please provide the information for the above, it would be helpful for me. Thanks, Ravindra (1 Reply)
Discussion started by: ravi3cha
1 Replies

6. Linux

ACL

Hi, I want to know what does the "effective" comment means in the output of the getfacl and whether it has to do with the acl mask... thanks (0 Replies)
Discussion started by: Gartlar
0 Replies

7. Shell Programming and Scripting

Need help to create ACL

Hi, I generated a script that will create the list of dir/sub-dir and will allow to create the same on diff server. this is what i have done : #!/bin/ksh # Script to migrate the directory between the two servers. # Ver 0.1 # Author Krishna. D # c - create and e - extract directory if ;... (1 Reply)
Discussion started by: krishnadvn
1 Replies

8. UNIX for Dummies Questions & Answers

arrow keys / special keys

how to use the arrow keys in shell scripting. is there any special synatax / command for this. i just want to use the arrow keys for navigation. replies appreciated raguram R (3 Replies)
Discussion started by: raguramtgr
3 Replies

9. Cybersecurity

ACL

Hi all, I've just been handled the responsibility for a FTP-site. Having no experiens of UNIX at all. And now one of my users needs to have full access to the usr directory and all it's subdirectories, don't know why just trying to do what the boss tells me. The type of UNIX is FreeBSD and the... (4 Replies)
Discussion started by: -tri-
4 Replies
Login or Register to Ask a Question