Sha256: 3f9202f3833d9cb0a2301fb9140a29e9a5e3e3244a30c30c05ec2e15d83403cd

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

class Support < Mapper
  #
  # Returns an array of resources.
  #
  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)

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

    [] # no Support subscription
  end

  private

  # not an error
  def suppressed_errors
    %w[
      AccessDeniedException
      SubscriptionRequiredException
    ]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws_recon-0.2.27 lib/aws_recon/collectors/support.rb
aws_recon-0.2.26 lib/aws_recon/collectors/support.rb
aws_recon-0.2.25 lib/aws_recon/collectors/support.rb