Class: S3Secure::Policy::Show

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

Instance Method Summary collapse

Methods inherited from CLI::Base

#buckets, #initialize

Methods included from CLI::Say

#say

Methods included from AwsServices

#sts

Methods included from AwsServices::S3

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

Constructor Details

This class inherits a constructor from S3Secure::CLI::Base

Instance Method Details

#policyObject



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

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
# File 'lib/s3_secure/policy/show.rb', line 3

def run
  if policy
    say "Bucket #{@bucket} is configured with this policy:"
    say policy
  else
    say "Bucket #{@bucket} is not configured bucket policy"
  end
end