Sha256: 513180f10e8b506968cc0a54109f90b922177b914f1df14bb243331aaad8cbdf

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

class Inventory::Ecs::Service < Inventory::Base
  def header
    ["Service", "Cluster", "Running Tasks"]
  end

  def data
    ecs_services.map do |service|
      [
        service.service_name,
        cluster_name(service.cluster_arn),
        service.running_count,
      ]
    end
  end

  def cluster_name(cluster_arn)
    resp = ecs.describe_clusters(clusters: [cluster_arn]) # cluster takes name or ARN
    resp.clusters.first.cluster_name
  end

  def ecs_services
    cluster_arns = ecs.list_clusters.cluster_arns
    @ecs_services ||= cluster_arns.map do |cluster_arn|
        service_arns = ecs.list_services(cluster: cluster_arn).service_arns
        resp = ecs.describe_services(services: service_arns, cluster: cluster_arn)
        resp.services
      end.flatten

    # pp @ecs_services
    # @ecs_services
    # @ecs_services ||= ecs.describe_services.services
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aws-inventory-0.2.0 lib/inventory/ecs/service.rb