Method: Support#collect

Defined in:
lib/aws_recon/collectors/support.rb

#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
# File 'lib/aws_recon/collectors/support.rb', line 10

def collect
  resources = []

  #
  # describe_trusted_advisor_checks
  #
  @client.describe_trusted_advisor_checks({ language: 'en' }).each_with_index do |response, page|
    log(response.context.operation_name, page)

    response.checks.each do |check|
      struct = OpenStruct.new(check.to_h)
      struct.type = 'trusted_advisor_check'
      struct.arn = "arn:aws:support::trusted_advisor_check/#{check.id}"

      # describe_trusted_advisor_check_result
      struct.result = @client.describe_trusted_advisor_check_result({ check_id: check.id }).result.to_h
      log(response.context.operation_name, 'describe_trusted_advisor_check_result', check.id)

      resources.push(struct.to_h)
    end
  end

  resources
rescue Aws::Support::Errors::ServiceError => e
  log_error(e.code)

  raise e unless suppressed_errors.include?(e.code) && !@options.quit_on_exception

  [] # no Support subscription
end