Class: S3Secure::Encryption::Show

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

Instance Method Summary collapse

Methods inherited from AbstractBase

#buckets, #initialize

Methods included from Say

#say

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

#enabled?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/s3_secure/encryption/show.rb', line 12

def enabled?
  !!(rules && !rules.empty?)
end

#rulesObject



16
17
18
19
20
# File 'lib/s3_secure/encryption/show.rb', line 16

def rules
  resp = s3.get_bucket_encryption(bucket: @bucket)
  resp.server_side_encryption_configuration.rules # Aws::Xml::DefaultList object
rescue Aws::S3::Errors::ServerSideEncryptionConfigurationNotFoundError
end

#runObject



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

def run
  if rules
    say "Bucket #{@bucket} is configured with these encryption rules:"
    say rules.map(&:to_h)
  else
    say "Bucket #{@bucket} is not configured with encryption at the bucket level"
  end
end