Sha256: 30959d2bcf2e6e15ba57e1f9ec93b631f3f05deda7d67dbf310d136df2aee183
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
module Heirloom module ACL class S3 def initialize(args) @config = args[:config] @region = args[:region] @logger = args[:logger] @accounts = @config.authorized_aws_accounts end def allow_read_acccess_from_accounts(args) bucket = args[:bucket] key_name = args[:key_name] key_folder = args[:key_folder] key = "#{key_folder}/#{key_name}.tar.gz" current_acls = s3.get_bucket_acl bucket name = current_acls['Owner']['Name'] id = current_acls['Owner']['ID'] grants = build_bucket_grants :id => id, :name => name, :accounts => @accounts @accounts.each do |a| @logger.info "Authorizing #{a} to s3://#{bucket}/#{key}" end s3.put_object_acl bucket, key, grants end private def build_bucket_grants(args) id = args[:id] name = args[:name] a = Array.new @accounts.each do |g| a << { 'Grantee' => { 'EmailAddress' => g } , 'Permission' => 'READ' } end { 'Owner' => { 'DisplayName' => name, 'ID' => id }, 'AccessControlList' => a } end def s3 @s3 ||= AWS::S3.new :config => @config, :region => @region end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
heirloom-0.1.2 | lib/heirloom/acl/s3.rb |
heirloom-0.1.1 | lib/heirloom/acl/s3.rb |