Class: S3Secure::Policy::Show

Inherits:
Base show all
Defined in:
lib/s3_secure/policy/show.rb

Instance Method Summary collapse

Methods inherited from AbstractBase

#buckets, #initialize

Methods included from AwsServices::S3

#check_bucket!, #new_s3_regional_client, #region, #region_map, #s3, #s3_client

Constructor Details

This class inherits a constructor from S3Secure::AbstractBase

Instance Method Details

#policyObject



13
14
15
16
17
18
# File 'lib/s3_secure/policy/show.rb', line 13

def policy
  resp = s3.get_bucket_policy(bucket: @bucket)
  data = JSON.load(resp.policy.read) # String
  JSON.pretty_generate(data)
rescue Aws::S3::Errors::NoSuchBucketPolicy
end

#runObject



3
4
5
6
7
8
9
10
11
# File 'lib/s3_secure/policy/show.rb', line 3

def run
  if policy
    puts "Bucket #{@bucket} is configured with this policy:"
    puts policy
    # puts policy.map(&:to_h)
  else
    puts "Bucket #{@bucket} is not configured bucket policy"
  end
end