module ContainerShip::Command::Modules::Ecs

Public Instance Methods

register(task_definition) click to toggle source
# 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) click to toggle source
# 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}"
    )
    .tasks
    .first
    .task_arn
end
update_service(task_definition, revision) click to toggle source
# 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) click to toggle source
# File lib/container_ship/command/modules/ecs.rb, line 33
def wait_task(task_definition, task_arn)
  do_every_5_seconds do
    aws_ecs_client.describe_tasks(cluster: task_definition.full_cluster_name, tasks: [task_arn])
      .tasks
      .first
      .containers
      .first
      .exit_code
  end
end

Private Instance Methods

aws_ecs_client() click to toggle source
# File lib/container_ship/command/modules/ecs.rb, line 46
def aws_ecs_client
  @aws_ecs_client ||= Aws::ECS::Client.new
end
do_every_5_seconds() { || ... } click to toggle source
# File lib/container_ship/command/modules/ecs.rb, line 50
def do_every_5_seconds
  count = 0
  loop do
    sleep 3
    print '.'
    exit_status = yield
    count += 1
    next if exit_status.nil?
    return 124 if count > 60

    return exit_status
  end
end