Class: Stax::Aws::Ecs

Inherits:
Sdk
  • Object
show all
Defined in:
lib/stax/aws/ecs.rb

Constant Summary

Constants inherited from Sdk

Sdk::RETRY_LIMIT

Class Method Summary collapse

Methods inherited from Sdk

paginate

Class Method Details

.clientObject



9
10
11
# File 'lib/stax/aws/ecs.rb', line 9

def client
  @_client ||= ::Aws::ECS::Client.new
end

.clusters(names) ⇒ Object



13
14
15
# File 'lib/stax/aws/ecs.rb', line 13

def clusters(names)
  client.describe_clusters(clusters: Array(names)).clusters
end

.instances(cluster) ⇒ Object



50
51
52
# File 'lib/stax/aws/ecs.rb', line 50

def instances(cluster)
  client.describe_container_instances(cluster: cluster, container_instances: list_instances(cluster)).container_instances
end

.list_instances(cluster) ⇒ Object



44
45
46
47
48
# File 'lib/stax/aws/ecs.rb', line 44

def list_instances(cluster)
  paginate(:container_instance_arns) do |token|
    client.list_container_instances(cluster: cluster, next_token: token)
  end
end

.list_tasks(opt) ⇒ Object



29
30
31
32
33
# File 'lib/stax/aws/ecs.rb', line 29

def list_tasks(opt)
  paginate(:task_arns) do |token|
    client.list_tasks(opt.merge(next_token: token))
  end
end

.run(cluster, task) ⇒ Object



54
55
56
# File 'lib/stax/aws/ecs.rb', line 54

def run(cluster, task)
  client.run_task(cluster: cluster, task_definition: task).tasks
end

.services(cluster, services) ⇒ Object



17
18
19
# File 'lib/stax/aws/ecs.rb', line 17

def services(cluster, services)
  client.describe_services(cluster: cluster, services: services).services
end

.stop(cluster, task) ⇒ Object



58
59
60
# File 'lib/stax/aws/ecs.rb', line 58

def stop(cluster, task)
  client.stop_task(cluster: cluster, task: task).task
end

.task_definition(name) ⇒ Object



25
26
27
# File 'lib/stax/aws/ecs.rb', line 25

def task_definition(name)
  client.describe_task_definition(task_definition: name).task_definition
end

.tasks(opt = {}) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/stax/aws/ecs.rb', line 35

def tasks(opt = {})
  tasks = list_tasks(opt)
  if tasks.empty?
    []
  else
    client.describe_tasks(cluster: opt[:cluster], tasks: tasks).tasks
  end
end

.update_service(opt) ⇒ Object



21
22
23
# File 'lib/stax/aws/ecs.rb', line 21

def update_service(opt)
  client.update_service(opt).service
end