Sha256: 21bd5b63ad1a4a0ecff905d00d0c35c1e969a413851e1c97e3e14605e29aa728

Contents?: true

Size: 1.07 KB

Versions: 54

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

#
# Collect CloudTrail resources
#
class CloudTrail < Mapper
  #
  # Returns an array of resources.
  #
  def collect
    resources = []
    #
    # describe_trails
    #
    @client.describe_trails.each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.trail_list.each do |trail|
        # list_tags needs to call into home_region
        client = if @region != trail.home_region
                   Aws::CloudTrail::Client.new({ region: trail.home_region })
                 else
                   @client
                 end

        struct = OpenStruct.new(trail.to_h)
        struct.tags = client.list_tags({ resource_id_list: [trail.trail_arn] }).resource_tag_list.first.tags_list.map(&:to_h)
        struct.type = 'cloud_trail'
        struct.event_selectors = client.get_event_selectors({ trail_name: trail.name }).to_h
        struct.status = client.get_trail_status({ name: trail.name }).to_h
        struct.arn = trail.trail_arn

        resources.push(struct.to_h)
      end
    end

    resources
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
aws_recon-0.5.33 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.32 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.31 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.30 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.29 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.28 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.27 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.26 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.25 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.24 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.23 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.22 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.21 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.20 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.19 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.18 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.17 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.16 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.15 lib/aws_recon/collectors/cloudtrail.rb
aws_recon-0.5.14 lib/aws_recon/collectors/cloudtrail.rb