Created
March 22, 2014 02:16
-
-
Save topher6345/847e91689df218246d8e to your computer and use it in GitHub Desktop.
Automatically set all permissions in bucket.
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
#!/usr/bin/ruby | |
# usage: set_permissions.rb [access_key_id] [secret_access_key] [bucket_name] | |
# ----------------------------------------------------------------------------- | |
# This script provides a means of updating all of the files in an S3 bucket to | |
# have the correct permissions. As this script is effectively throwaway it | |
# doesn't do much beyond making sure it runs at least once, however, is worth | |
# keeping around as a reference in the event the problem arises again. | |
# ----------------------------------------------------------------------------- | |
require 'rubygems' | |
require 'aws-sdk' | |
# Note the configuration points | |
AWS.config({ | |
:access_key_id => ARGV[0], | |
:secret_access_key => ARGV[1], | |
}) | |
bucket_name = ARGV[2] | |
# Get the bucket information | |
s3 = AWS::S3.new | |
bucket = s3.buckets[bucket_name] | |
# Update the ACL for each item in the bucket | |
bucket.objects.each do|obj| | |
puts obj.key | |
obj.acl = :public_read | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment