Class: EcsDeployer::ScheduledTask::Target
- Inherits:
-
Object
- Object
- EcsDeployer::ScheduledTask::Target
- Defined in:
- lib/ecs_deployer/scheduled_task/target.rb
Instance Attribute Summary collapse
-
#cloudwatch_event_role_arn ⇒ Object
Returns the value of attribute cloudwatch_event_role_arn.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#task_count ⇒ Object
Returns the value of attribute task_count.
-
#task_definition_arn ⇒ Object
Returns the value of attribute task_definition_arn.
-
#task_role_arn ⇒ Object
Returns the value of attribute task_role_arn.
Instance Method Summary collapse
-
#initialize(cluster, id, aws_options = {}) ⇒ Target
constructor
A new instance of Target.
- #override_container(name, command = nil, environments = {}) ⇒ Object
- #to_hash ⇒ Hash
Constructor Details
#initialize(cluster, id, aws_options = {}) ⇒ Target
Returns a new instance of Target.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 11 def initialize(cluster, id, = {}) ecs = Aws::ECS::Client.new() clusters = ecs.describe_clusters(clusters: [cluster]).clusters raise ClusterNotFoundError, "Cluster does not eixst. [#{cluster}]" if clusters.count.zero? @id = id @arn = clusters[0].cluster_arn @task_count = 1 @container_overrides = [] end |
Instance Attribute Details
#cloudwatch_event_role_arn ⇒ Object
Returns the value of attribute cloudwatch_event_role_arn.
5 6 7 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 5 def cloudwatch_event_role_arn @cloudwatch_event_role_arn end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 4 def id @id end |
#task_count ⇒ Object
Returns the value of attribute task_count.
5 6 7 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 5 def task_count @task_count end |
#task_definition_arn ⇒ Object
Returns the value of attribute task_definition_arn.
5 6 7 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 5 def task_definition_arn @task_definition_arn end |
#task_role_arn ⇒ Object
Returns the value of attribute task_role_arn.
5 6 7 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 5 def task_role_arn @task_role_arn end |
Instance Method Details
#override_container(name, command = nil, environments = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 25 def override_container(name, command = nil, environments = {}) override_environments = [] environments.each do |environment| environment.each do |env_name, env_value| override_environments << { name: env_name, value: env_value } end end container_override = { name: name, command: command } container_override[:environment] = override_environments if override_environments.count > 0 @container_overrides << container_override end |
#to_hash ⇒ Hash
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ecs_deployer/scheduled_task/target.rb', line 46 def to_hash { id: @id, arn: @arn, role_arn: @cloudwatch_event_role_arn, ecs_parameters: { task_definition_arn: @task_definition_arn, task_count: @task_count }, input: { taskRoleArn: @task_role_arn, containerOverrides: @container_overrides }.to_json.to_s } end |