Class: ECSHelper::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ecs_helper/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
9
10
11
# File 'lib/ecs_helper/client.rb', line 7

def initialize
  @ecs = Aws::ECS::Client.new
  @ecr = Aws::ECR::Client.new
  @ssm = Aws::SSM::Client.new
end

Instance Attribute Details

#ecrObject

Returns the value of attribute ecr.



6
7
8
# File 'lib/ecs_helper/client.rb', line 6

def ecr
  @ecr
end

#ecsObject

Returns the value of attribute ecs.



6
7
8
# File 'lib/ecs_helper/client.rb', line 6

def ecs
  @ecs
end

#ssmObject

Returns the value of attribute ssm.



6
7
8
# File 'lib/ecs_helper/client.rb', line 6

def ssm
  @ssm
end

Instance Method Details

#clustersObject



18
19
20
# File 'lib/ecs_helper/client.rb', line 18

def clusters
  @clusters ||= ecs.list_clusters.cluster_arns
end

#describe_images(params = {}) ⇒ Object



68
69
70
# File 'lib/ecs_helper/client.rb', line 68

def describe_images(params = {})
  ecr.describe_images(params).image_details[0]
end

#describe_service(cluster, service) ⇒ Object



31
32
33
# File 'lib/ecs_helper/client.rb', line 31

def describe_service(cluster, service)
  ecs.describe_services(cluster: cluster, services: [service]).services[0]
end

#describe_task_definition(task_definition) ⇒ Object



35
36
37
# File 'lib/ecs_helper/client.rb', line 35

def describe_task_definition(task_definition)
  ecs.describe_task_definition(task_definition: task_definition).task_definition
end

#describe_tasks(params = {}) ⇒ Object



51
52
53
# File 'lib/ecs_helper/client.rb', line 51

def describe_tasks(params = {})
  ecs.describe_tasks(params).tasks
end

#execute_command(params = {}) ⇒ Object



59
60
61
# File 'lib/ecs_helper/client.rb', line 59

def execute_command(params = {})
  ecs.execute_command(params)
end

#get_ssm_parameters(params = {}) ⇒ Object

SSM



73
74
75
# File 'lib/ecs_helper/client.rb', line 73

def get_ssm_parameters(params = {})
  ssm.get_parameters(params).parameters
end

#list_tasks(params = {}) ⇒ Object



55
56
57
# File 'lib/ecs_helper/client.rb', line 55

def list_tasks(params = {})
  ecs.list_tasks(params).task_arns
end

#private_repositories(params = {}) ⇒ Object

ECR



64
65
66
# File 'lib/ecs_helper/client.rb', line 64

def private_repositories(params = {})
  ecr.describe_repositories(params).repositories
end

#register_task_definition(params = {}) ⇒ Object



39
40
41
# File 'lib/ecs_helper/client.rb', line 39

def register_task_definition(params = {})
  ecs.register_task_definition(params).task_definition
end

#run_task(params = {}) ⇒ Object



47
48
49
# File 'lib/ecs_helper/client.rb', line 47

def run_task(params = {})
  ecs.run_task(params).tasks[0]
end

#services(cluster) ⇒ Object



22
23
24
# File 'lib/ecs_helper/client.rb', line 22

def services(cluster)
  @services ||= ecs.list_services(cluster: cluster).service_arns
end

#task_definitionsObject

ECS



14
15
16
# File 'lib/ecs_helper/client.rb', line 14

def task_definitions
  @task_definitions ||= ecs.list_task_definitions.task_definition_arns
end

#tasks(cluster, service) ⇒ Object



26
27
28
29
# File 'lib/ecs_helper/client.rb', line 26

def tasks(cluster, service)
  arns = ecs.list_tasks(cluster: cluster, service_name: service).task_arns
  ecs.describe_tasks({ tasks: arns, cluster: cluster }).tasks
end

#update_service(params = {}) ⇒ Object



43
44
45
# File 'lib/ecs_helper/client.rb', line 43

def update_service(params = {})
  ecs.update_service(params)
end