Class: EcsDeployCli::DSL::Cron
- Inherits:
-
Object
- Object
- EcsDeployCli::DSL::Cron
show all
- Includes:
- AutoOptions
- Defined in:
- lib/ecs_deploy_cli/dsl/cron.rb
Defined Under Namespace
Classes: Container, Task
Instance Method Summary
collapse
#_options, #method_missing
Constructor Details
#initialize(name, config) ⇒ Cron
Returns a new instance of Cron.
8
9
10
11
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 8
def initialize(name, config)
_options[:name] = name
@config = config
end
|
Instance Method Details
#as_definition(tasks) ⇒ Object
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
73
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 46
def as_definition(tasks)
raise 'Missing task definition' unless _options[:task]
input = { 'containerOverrides' => _options[:task].as_definition }
input['taskRoleArn'] = _options[:task_role] if _options[:task_role]
{
task_name: _options[:task].name,
rule: {
name: _options[:name],
schedule_expression: @cron_expression || @every || raise("Missing schedule expression.")
},
input: input,
ecs_parameters: {
task_count: _options[:task_count] || 1,
launch_type: _options[:launch_type] || raise('Missing parameter launch_type'),
network_configuration: {
awsvpc_configuration: {
subnets: _options[:subnets] || raise('Missing parameter subnets'),
security_groups: _options[:security_groups] || [],
assign_public_ip: _options[:assign_public_ip] ? 'ENABLED' : 'DISABLED'
}
},
platform_version: _options[:platform_version] || 'LATEST'
}
}
end
|
#assign_public_ip(value) ⇒ Object
42
43
44
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 42
def assign_public_ip(value)
_options[:assign_public_ip] = value
end
|
#launch_type(value) ⇒ Object
38
39
40
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 38
def launch_type(value)
_options[:launch_type] = value
end
|
#run_at(cron_expression) ⇒ Object
18
19
20
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 18
def run_at(cron_expression)
@cron_expression = "cron(#{cron_expression})"
end
|
#run_every(interval) ⇒ Object
22
23
24
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 22
def run_every(interval)
@every = "rate(#{interval})"
end
|
#security_groups(*value) ⇒ Object
34
35
36
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 34
def security_groups(*value)
_options[:security_groups] = value
end
|
#subnets(*value) ⇒ Object
30
31
32
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 30
def subnets(*value)
_options[:subnets] = value
end
|
#task(name, &block) ⇒ Object
13
14
15
16
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 13
def task(name, &block)
_options[:task] = Task.new(name.to_s, @config)
_options[:task].instance_exec(&block)
end
|
#task_role(role) ⇒ Object
26
27
28
|
# File 'lib/ecs_deploy_cli/dsl/cron.rb', line 26
def task_role(role)
_options[:task_role] = "arn:aws:iam::#{@config[:aws_profile_id]}:role/#{role}"
end
|