Sha256: 47d6f588304636302a0563d4cb2e6e0a8be4f5062a17a0a42835d1e42bd95629

Contents?: true

Size: 2 KB

Versions: 9

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

#
# Collect EMR resources
#
class EMR < Mapper
  #
  # Returns an array of resources.
  #
  def collect
    resources = []

    #
    # get_block_public_access_configuration
    #
    begin
      @client.get_block_public_access_configuration.each do |response|
        log(response.context.operation_name)

        struct = OpenStruct.new(response.block_public_access_configuration.to_h)
        struct.type = 'configuration'
        struct.arn = "arn:aws:emr:#{@region}:#{@account}/block_public_access_configuration"

        resources.push(struct.to_h)
      end
    rescue Aws::EMR::Errors::ServiceError => e
      log_error(e.code)

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

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

      response.clusters.each do |cluster|
        log(response.context.operation_name, cluster.id)

        struct = OpenStruct.new(@client.describe_cluster({ cluster_id: cluster.id }).cluster.to_h)
        struct.type = 'cluster'
        struct.arn = cluster.cluster_arn

        resources.push(struct.to_h)
      end
    end

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

      response.security_configurations.each do |security_configuration|
        log(response.context.operation_name, security_configuration.name)

        struct = OpenStruct.new(@client.describe_security_configuration({ name: security_configuration.name }).security_configuration.parse_policy)
        struct.type = 'security_configuration'
        struct.arn = "arn:aws:emr:#{@region}:#{@account}:security-configuration/#{security_configuration.name}" # no true ARN
        resources.push(struct.to_h)
      end
    end

    resources
  end

  private

  def suppressed_errors
    %w[
      InvalidRequestException
    ]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aws_recon-0.5.33 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.32 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.31 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.30 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.29 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.28 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.27 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.26 lib/aws_recon/collectors/emr.rb
aws_recon-0.5.25 lib/aws_recon/collectors/emr.rb