Class: Shipitron::Client::RunEcsTasks

Inherits:
Object
  • Object
show all
Includes:
Metaractor, EcsClient
Defined in:
lib/shipitron/client/run_ecs_tasks.rb

Instance Method Summary collapse

Methods included from EcsClient

#ecs_client, #generate_ecs_client

Instance Method Details

#callObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/shipitron/client/run_ecs_tasks.rb', line 34

def call
  Logger.info "Skipping ECS run_task calls due to --simulate" if simulate?

  clusters.each do |cluster|
    begin
      if simulate?
        command_args(cluster)
        next
      end

      response = ecs_client(region: cluster.region).run_task(
        cluster: cluster.name,
        task_definition: shipitron_task,
        overrides: {
          container_overrides: [
            {
              name: 'shipitron',
              command: command_args(cluster)
            }
          ]
        },
        count: 1,
        started_by: 'shipitron'
      )

      if !response.failures.empty?
        response.failures.each do |failure|
          fail_with_error! message: "ECS run_task failure: #{failure.arn}: #{failure.reason}"
        end
      end

    rescue Aws::ECS::Errors::ServiceError => e
      fail_with_errors!(messages: [
        "Error: #{e.message}",
        e.backtrace.join("\n")
      ])
    end
  end
end