class Bukelatta::Driver
Public Class Methods
new(client, options = {})
click to toggle source
# File lib/bukelatta/driver.rb, line 5 def initialize(client, options = {}) @client = client @resource = Aws::S3::Resource.new(client: @client) @options = options end
Public Instance Methods
create_policy(bucket_name, policy)
click to toggle source
# File lib/bukelatta/driver.rb, line 11 def create_policy(bucket_name, policy) log(:info, "Create Bucket `#{bucket_name}` Policy", color: :cyan) unless @options[:dry_run] bucket = @resource.bucket(bucket_name) bucket.auto_redirect do |b| b.policy.put(policy: JSON.dump(policy)) end end end
delete_policy(bucket_name)
click to toggle source
# File lib/bukelatta/driver.rb, line 23 def delete_policy(bucket_name) log(:info, "Delete Bucket `#{bucket_name}` Policy", color: :red) unless @options[:dry_run] bucket = @resource.bucket(bucket_name) bucket.auto_redirect do |b| b.policy.delete end end end
update_policy(bucket_name, policy, old_policy)
click to toggle source
# File lib/bukelatta/driver.rb, line 35 def update_policy(bucket_name, policy, old_policy) log(:info, "Update Bucket `#{bucket_name}` Policy", color: :green) log(:info, diff(old_policy, policy, color: @options[:color]), color: false) unless @options[:dry_run] bucket = @resource.bucket(bucket_name) bucket.auto_redirect do |b| b.policy.put(policy: JSON.dump(policy)) end end end