class Awspec::Type::S3Bucket
Public Instance Methods
acl_grants_count()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 36 def acl_grants_count @acl = find_bucket_acl(id) @acl.grants.count end
acl_owner()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 31 def acl_owner @acl = find_bucket_acl(id) @acl.owner.display_name end
cors_rules_count()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 55 def cors_rules_count cors_rules.count end
has_acl_grant?(grantee:, permission:)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 23 def has_acl_grant?(grantee:, permission:) @acl = find_bucket_acl(id) @acl.grants.find do |grant| grant.permission == permission && (grant.grantee.display_name == grantee || grant.grantee.uri == grantee || grant.grantee.id == grantee) end end
has_cors_rule?(allowed_headers: [], allowed_methods:, allowed_origins:, expose_headers: [], max_age_seconds: nil)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 41 def has_cors_rule?(allowed_headers: [], allowed_methods:, allowed_origins:, expose_headers: [], max_age_seconds: nil) cors_rules.any? do |rule| (rule.allowed_headers - allowed_headers).empty? && (rule.allowed_methods - allowed_methods).empty? && (rule.allowed_origins - allowed_origins).empty? && (rule.expose_headers - expose_headers).empty? && rule.max_age_seconds == max_age_seconds end end
has_lifecycle_rule?(rule)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 89 def has_lifecycle_rule?(rule) lifecycle_configuration_rules.any? do |lc_rule| rule.each { |key, value| lc_rule[key] == value } end end
has_logging_enabled?(target_bucket: nil, target_prefix: nil)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 74 def has_logging_enabled?(target_bucket: nil, target_prefix: nil) bl = find_bucket_logging(id) le = bl ? bl.logging_enabled : nil return false if le.nil? return false if target_bucket && target_bucket != le.target_bucket return false if target_prefix && target_prefix != le.target_prefix true end
has_mfa_delete_enabled?()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 95 def has_mfa_delete_enabled? bv = find_bucket_versioning(id) bv ? (bv.mfa_delete == 'Enabled') : false end
has_object?(key)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 13 def has_object?(key) res = s3_client.head_object({ bucket: id, key: key.sub(%r(\A/), '') }) res rescue false end
has_policy?(policy)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 59 def has_policy?(policy) bp = find_bucket_policy(id) if bp JSON.parse(bp.policy.read, array_class: Set) == JSON.parse(policy, array_class: Set) else false end end
has_tag?(key, value)
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 68 def has_tag?(key, value) tag = find_bucket_tag(id, key) return nil if tag.value != value tag end
has_versioning_enabled?()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 84 def has_versioning_enabled? bv = find_bucket_versioning(id) bv ? (bv.status == 'Enabled') : false end
id()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 9 def id @id ||= @display_name if resource_via_client end
resource_via_client()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 5 def resource_via_client @resource_via_client ||= find_bucket(@display_name) end
Private Instance Methods
cors_rules()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 102 def cors_rules cors = find_bucket_cors(id) cors ? cors.cors_rules : [] end
lifecycle_configuration_rules()
click to toggle source
# File lib/awspec/type/s3_bucket.rb, line 107 def lifecycle_configuration_rules blc = find_bucket_lifecycle_configuration(id) blc ? blc.rules : [] end