Created
September 20, 2010 19:40
-
-
Save batok/588524 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this snippet will let | |
#assign full access RWD to a specific bucket to an already created user ( with iam ) | |
# works with python 2.7 | |
import boto, sys, json | |
c = boto.connect_iam() | |
if len(sys.argv) == 2: | |
c.get_all_user_policies(sys.argv[1]) | |
exit(1) | |
user, bucket = sys.argv[1:] | |
bucket_policy_name = "bucket_{}_{}{}".format(bucket, user[0].upper(),user[1:]) | |
bucket_policy_contents_name = "bucket_contents_{}_{}{}".format(bucket, user[0].upper(),user[1:]) | |
policy_1 = json.dumps(dict( Statement = [ dict(Effect = "Allow", Action = "*" , Resource = "arn:aws:s3:::{}*".format( bucket )),])) | |
policy_2 = json.dumps(dict( Statement = [ dict(Effect = "Allow", Action = "*" , Resource = "arn:aws:s3:::{}/*".format( bucket )),])) | |
response = c.put_user_policy( user, bucket_policy_name, policy_1) | |
response = c.put_user_policy( user, bucket_policy_contents_name, policy_2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment