Class: EcsDeploy::ScheduledTask

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_deploy/scheduled_task.rb

Defined Under Namespace

Classes: PutTargetsFailure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster:, rule_name:, schedule_expression:, task_definition_name:, role_arn:, region: nil, **options) ⇒ ScheduledTask

Returns a new instance of ScheduledTask.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ecs_deploy/scheduled_task.rb', line 10

def initialize(cluster:, rule_name:, schedule_expression:, task_definition_name:, role_arn:, region: nil, **options)
  @cluster = cluster
  @rule_name = rule_name
  @schedule_expression = schedule_expression
  @task_definition_name = task_definition_name
  @role_arn = role_arn

  @options = options.dup
  @options[:enabled] = @options.fetch(:enabled, true)
  @options[:target_id] ||= task_definition_name
  @options[:task_count] ||= 1
  @options[:launch_type] ||= "EC2"

  region ||= EcsDeploy.config.default_region
  params ||= EcsDeploy.config.ecs_client_params

  @client = region ? Aws::ECS::Client.new(params.merge(region: region)) : Aws::ECS::Client.new(params)
  @region = @client.config.region
  @cloud_watch_events = Aws::CloudWatchEvents::Client.new(region: @region)
end

Instance Attribute Details

#clusterObject (readonly)

Returns the value of attribute cluster.



8
9
10
# File 'lib/ecs_deploy/scheduled_task.rb', line 8

def cluster
  @cluster
end

#regionObject (readonly)

Returns the value of attribute region.



8
9
10
# File 'lib/ecs_deploy/scheduled_task.rb', line 8

def region
  @region
end

#schedule_rule_nameObject (readonly)

Returns the value of attribute schedule_rule_name.



8
9
10
# File 'lib/ecs_deploy/scheduled_task.rb', line 8

def schedule_rule_name
  @schedule_rule_name
end

Instance Method Details

#deployObject



31
32
33
34
# File 'lib/ecs_deploy/scheduled_task.rb', line 31

def deploy
  put_rule
  put_targets
end