Sha256: e6f22ee3863f9d5e12a2f1dbf6185c1868e3efe4754eb7f283656acfa052298d

Contents?: true

Size: 990 Bytes

Versions: 25

Compression:

Stored size: 990 Bytes

Contents

class ECS < Mapper
  #
  # Returns an array of resources.
  #
  # TODO: test live
  #
  def collect
    resources = []

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

      response.clusters.each do |cluster|
        struct = OpenStruct.new(cluster.to_h)
        struct.type = 'cluster'
        struct.arn = cluster.cluster_arn
        struct.tasks = []

        # list_tasks
        @client.list_tasks({ cluster: cluster.cluster_arn }).each_with_index do |response, page|
          log(response.context.operation_name, 'list_tasks', page)

          # describe_tasks
          response.task_arns.each do |task_arn|
            @client.describe_tasks({ cluster: cluster.cluster_arn, tasks: [task_arn] }).tasks.each do |task|
              struct.tasks.push(task)
            end
          end
        end

        resources.push(struct.to_h)
      end
    end

    resources
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
aws_recon-0.2.5 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.4 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.3 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.2 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.1 lib/aws_recon/collectors/ecs.rb