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.25 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.24 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.23 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.22 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.21 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.20 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.19 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.18 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.17 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.16 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.15 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.14 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.13 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.12 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.11 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.10 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.9 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.8 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.7 lib/aws_recon/collectors/ecs.rb
aws_recon-0.2.6 lib/aws_recon/collectors/ecs.rb