Class: Inventory::Ecs::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/inventory/ecs/service.rb

Instance Method Summary collapse

Methods inherited from Base

eager_load!, inherited, #initialize, #report, #show, #sort, subclasses, #test_mode

Methods included from AwsServices

#acm, #cfn, #cw, #eb, #ec2, #ecs, #elbv1, #elbv2, #iam, #pricing, #rds, #route53

Methods included from Shared

#instances, #security_groups

Constructor Details

This class inherits a constructor from Inventory::Base

Instance Method Details

#cluster_name(cluster_arn) ⇒ Object



16
17
18
19
# File 'lib/inventory/ecs/service.rb', line 16

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

#dataObject



6
7
8
9
10
11
12
13
14
# File 'lib/inventory/ecs/service.rb', line 6

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

#ecs_servicesObject



21
22
23
24
25
26
27
28
# File 'lib/inventory/ecs/service.rb', line 21

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
end

#headerObject



2
3
4
# File 'lib/inventory/ecs/service.rb', line 2

def header
  ["Service", "Cluster", "Running Tasks"]
end