Class: AwsCloudTrailTrail

Inherits:
Object
  • Object
show all
Includes:
AwsSingularResourceMixin
Defined in:
lib/resources/aws/aws_cloudtrail_trail.rb

Defined Under Namespace

Classes: Backend

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AwsSingularResourceMixin

#exists?, included

Methods included from AwsResourceMixin

#catch_aws_errors, #check_resource_param_names, #initialize, #inspec_runner

Instance Attribute Details

#cloud_watch_logs_log_group_arnObject (readonly)

Returns the value of attribute cloud_watch_logs_log_group_arn.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def cloud_watch_logs_log_group_arn
  @cloud_watch_logs_log_group_arn
end

#cloud_watch_logs_role_arnObject (readonly)

Returns the value of attribute cloud_watch_logs_role_arn.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def cloud_watch_logs_role_arn
  @cloud_watch_logs_role_arn
end

#home_regionObject (readonly)

Returns the value of attribute home_region.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def home_region
  @home_region
end

#kms_key_idObject (readonly)

Returns the value of attribute kms_key_id.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def kms_key_id
  @kms_key_id
end

#s3_bucket_nameObject (readonly)

Returns the value of attribute s3_bucket_name.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def s3_bucket_name
  @s3_bucket_name
end

#trail_arnObject (readonly)

Returns the value of attribute trail_arn.



13
14
15
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 13

def trail_arn
  @trail_arn
end

Instance Method Details

#delivered_logs_days_agoObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 32

def delivered_logs_days_ago
  query = { name: @trail_name }
  catch_aws_errors do
    begin
      resp = BackendFactory.create(inspec_runner).get_trail_status(query).to_h
      ((Time.now - resp[:latest_cloud_watch_logs_delivery_time])/(24*60*60)).to_i unless resp[:latest_cloud_watch_logs_delivery_time].nil?
    rescue Aws::CloudTrail::Errors::TrailNotFoundException
      nil
    end
  end
end

#encrypted?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 28

def encrypted?
  !kms_key_id.nil?
end

#log_file_validation_enabled?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 24

def log_file_validation_enabled?
  @log_file_validation_enabled
end

#multi_region_trail?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 20

def multi_region_trail?
  @is_multi_region_trail
end

#to_sObject



16
17
18
# File 'lib/resources/aws/aws_cloudtrail_trail.rb', line 16

def to_s
  "CloudTrail #{@trail_name}"
end