Class: ConfigService

Inherits:
Mapper show all
Defined in:
lib/aws_recon/collectors/configservice.rb

Overview

Collect Config resources

Constant Summary

Constants inherited from Mapper

Mapper::SINGLE_REGION_SERVICES

Instance Method Summary collapse

Methods inherited from Mapper

#initialize

Constructor Details

This class inherits a constructor from Mapper

Instance Method Details

#collectObject

Returns an array of resources.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/aws_recon/collectors/configservice.rb', line 10

def collect
  resources = []

  #
  # describe_config_rules
  #
  @client.describe_config_rules.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.config_rules.each do |rule|
      struct = OpenStruct.new(rule.to_h)
      struct.type = 'rule'
      struct.arn = rule.config_rule_arn

      # describe_config_rule_evaluation_status
      @client.describe_config_rule_evaluation_status({ config_rule_names: [rule.config_rule_name] }).each do |response|
        log(response.context.operation_name, rule.config_rule_name, page)

        response.config_rules_evaluation_status.each do |status|
          struct.evaluation_status = status.to_h
        end
      end

      resources.push(struct.to_h)
    end
  end

  #
  # describe_configuration_recorders
  #
  @client.describe_configuration_recorders.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.configuration_recorders.each do |recorder|
      struct = OpenStruct.new(recorder.to_h)
      struct.type = 'configuration_recorder'
      struct.arn = "arn:aws:config:#{@region}:#{@account}:configuration_recorder/#{recorder.name}"

      # describe_configuration_recorder_status (only accepts one recorder)
      @client.describe_configuration_recorder_status({ configuration_recorder_names: [recorder.name] }).each do |response|
        log(response.context.operation_name, recorder.name, page)

        response.configuration_recorders_status.each do |status|
          struct.status = status.to_h
        end
      end

      resources.push(struct.to_h)
    end
  end

  #
  # describe_delivery_channels
  #
  @client.describe_delivery_channels.each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.delivery_channels.each do |channel|
      struct = OpenStruct.new(channel.to_h)
      struct.type = 'delivery_channel'
      struct.arn = "arn:aws:config:#{@region}:delivery_channel/#{channel.name}"

      # describe_delivery_channel_status (only accepts one channel)
      @client.describe_delivery_channel_status({ delivery_channel_names: [channel.name] }).each do |response|
        response.delivery_channels_status.each do |status|
          struct.status = status.to_h
        end
      end

      resources.push(struct.to_h)
    end
  end

  resources
end