Class: AwsS3Bucket
- Inherits:
-
Object
- Object
- AwsS3Bucket
- Includes:
- AwsSingularResourceMixin
- Defined in:
- lib/resources/aws/aws_s3_bucket.rb
Overview
author: Matthew Dromazos
Defined Under Namespace
Classes: Backend
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#has_access_logging_enabled ⇒ Object
readonly
Returns the value of attribute has_access_logging_enabled.
-
#has_default_encryption_enabled ⇒ Object
readonly
Returns the value of attribute has_default_encryption_enabled.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Instance Method Summary collapse
- #bucket_acl ⇒ Object
- #bucket_policy ⇒ Object
- #has_access_logging_enabled? ⇒ Boolean
- #has_default_encryption_enabled? ⇒ Boolean
-
#public? ⇒ Boolean
RSpec will alias this to be_public.
- #to_s ⇒ Object
Methods included from AwsSingularResourceMixin
Methods included from AwsResourceMixin
#catch_aws_errors, #check_resource_param_names, #initialize, #inspec_runner
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
13 14 15 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 13 def bucket_name @bucket_name end |
#has_access_logging_enabled ⇒ Object (readonly)
Returns the value of attribute has_access_logging_enabled.
13 14 15 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 13 def has_access_logging_enabled @has_access_logging_enabled end |
#has_default_encryption_enabled ⇒ Object (readonly)
Returns the value of attribute has_default_encryption_enabled.
13 14 15 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 13 def has_default_encryption_enabled @has_default_encryption_enabled end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
13 14 15 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 13 def region @region end |
Instance Method Details
#bucket_acl ⇒ Object
19 20 21 22 23 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 19 def bucket_acl catch_aws_errors do @bucket_acl ||= BackendFactory.create(inspec_runner).get_bucket_acl(bucket: bucket_name).grants end end |
#bucket_policy ⇒ Object
25 26 27 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 25 def bucket_policy @bucket_policy ||= fetch_bucket_policy end |
#has_access_logging_enabled? ⇒ Boolean
43 44 45 46 47 48 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 43 def has_access_logging_enabled? return false unless @exists catch_aws_errors do @has_access_logging_enabled ||= !BackendFactory.create(inspec_runner).get_bucket_logging(bucket: bucket_name).logging_enabled.nil? end end |
#has_default_encryption_enabled? ⇒ Boolean
38 39 40 41 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 38 def has_default_encryption_enabled? return false unless @exists @has_default_encryption_enabled ||= fetch_bucket_encryption_configuration end |
#public? ⇒ Boolean
RSpec will alias this to be_public
30 31 32 33 34 35 36 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 30 def public? # first line just for formatting false || \ bucket_acl.any? { |g| g.grantee.type == 'Group' && g.grantee.uri =~ /AllUsers/ } || \ bucket_acl.any? { |g| g.grantee.type == 'Group' && g.grantee.uri =~ /AuthenticatedUsers/ } || \ bucket_policy.any? { |s| s.effect == 'Allow' && s.principal == '*' } end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/resources/aws/aws_s3_bucket.rb', line 15 def to_s "S3 Bucket #{@bucket_name}" end |