Class: EcsDeployCli::Runners::UpdateCrons

Inherits:
Base
  • Object
show all
Defined in:
lib/ecs_deploy_cli/runners/update_crons.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #update_task

Constructor Details

This class inherits a constructor from EcsDeployCli::Runners::Base

Instance Method Details

#run!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ecs_deploy_cli/runners/update_crons.rb', line 6

def run!
  _, tasks, crons = @parser.resolve

  crons.each do |cron_name, cron_definition|
    task_definition = tasks[cron_definition[:task_name]]
    unless task_definition
      raise "Undefined task #{cron_definition[:task_name].inspect} in (#{tasks.keys.inspect})"
    end

    updated_task = _update_task(task_definition)

    current_target = load_or_init_target(cron_name)

    cwe_client.put_rule(
      cron_definition[:rule]
    )

    cwe_client.put_targets(
      rule: cron_name,
      targets: [
        id: current_target[:id],
        arn: current_target[:arn],
        role_arn: current_target[:role_arn],
        input: cron_definition[:input].to_json,
        ecs_parameters: cron_definition[:ecs_parameters].merge(task_definition_arn: updated_task[:task_definition_arn])
      ]
    )
    EcsDeployCli.logger.info "Deployed scheduled task \"#{cron_name}\"!"
  end
end