Module: ContainerShip::Command::Modules::Ecs

Included in:
ExecCommand, ShipCommand
Defined in:
lib/container_ship/command/modules/ecs.rb

Instance Method Summary collapse

Instance Method Details

#register(task_definition) ⇒ Object



7
8
9
10
11
12
# File 'lib/container_ship/command/modules/ecs.rb', line 7

def register(task_definition)
  aws_ecs_client
    .register_task_definition(task_definition.to_h)
    .task_definition
    .revision
end

#run_task(task_definition, revision) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/container_ship/command/modules/ecs.rb', line 22

def run_task(task_definition, revision)
  aws_ecs_client
    .run_task(
      cluster: task_definition.full_cluster_name,
      task_definition: "#{task_definition.full_name}:#{revision}",
      **task_definition.run_task_options
    )
    .tasks
    .first
    .task_arn
end

#update_service(task_definition, revision) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/container_ship/command/modules/ecs.rb', line 14

def update_service(task_definition, revision)
  aws_ecs_client.update_service(
    cluster: task_definition.full_cluster_name,
    service: task_definition.full_name,
    task_definition: "#{task_definition.full_name}:#{revision}"
  )
end

#wait_task(task_definition, task_arn, timeout: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/container_ship/command/modules/ecs.rb', line 34

def wait_task(task_definition, task_arn, timeout: nil)
  do_every_5_seconds(timeout: timeout) do
    aws_ecs_client.describe_tasks(cluster: task_definition.full_cluster_name, tasks: [task_arn])
      .tasks
      .first
      .containers
      .first
      .exit_code
  end
end