Class: Ufo::Info
Instance Attribute Summary
Attributes inherited from CLI::Base
#task_definition
Instance Method Summary
collapse
#acm, #applicationautoscaling, #aws_options, #cloudformation, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #find_stack, #ssm_client, #status, #task_definition_arns, #waf_client
Methods inherited from CLI::Base
#initialize
#sure?
#pretty_home, #pretty_path, #pretty_time
#logger
Methods included from Concerns
#build, #deploy, #info, #ps
#names
Constructor Details
This class inherits a constructor from Ufo::CLI::Base
Instance Method Details
#load_balancer(service) ⇒ Object
Passing in service so method can be used else where.
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/ufo/info.rb', line 22
def load_balancer(service)
load_balancer = service.load_balancers.first
return unless load_balancer
resp = elb.describe_target_groups(
target_group_arns: [load_balancer.target_group_arn]
)
target_group = resp.target_groups.first
load_balancer_arn = target_group.load_balancer_arns.first
resp = elb.describe_load_balancers(load_balancer_arns: [load_balancer_arn])
resp.load_balancers.first
end
|
#no_service_message ⇒ Object
17
18
19
|
# File 'lib/ufo/info.rb', line 17
def no_service_message
"No stack #{@stack_name.color(:green)} found"
end
|
#run ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/ufo/info.rb', line 5
def run
unless service
puts no_service_message
return
end
puts "Resources:"
stack_resources.each do |r|
puts "#{r.logical_resource_id} - #{r.resource_type}:".color(:green)
puts " #{r.physical_resource_id}"
end
end
|
#service ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/ufo/info.rb', line 37
def service
return unless stack
service = stack_resources.find { |r| r.resource_type == "AWS::ECS::Service" }
return unless service arn = service.physical_resource_id
return unless arn resp = ecs.describe_services(services: [arn], cluster: @cluster)
resp.services.first
end
|
#service? ⇒ Boolean
49
50
51
|
# File 'lib/ufo/info.rb', line 49
def service?
!!service
end
|
#stack ⇒ Object
53
54
55
|
# File 'lib/ufo/info.rb', line 53
def stack
find_stack(@stack_name)
end
|
#stack_resources ⇒ Object
75
76
77
78
|
# File 'lib/ufo/info.rb', line 75
def stack_resources
resp = cloudformation.describe_stack_resources(stack_name: @stack_name)
resp.stack_resources
end
|
#url ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/ufo/info.rb', line 58
def url
return unless stack
output = stack.outputs.find do |o|
o.output_key == "Route53Dns"
end
dns_name = output.output_value if output
return unless dns_name
ssl = stack_resources.find do |r|
r.logical_resource_id == "ListenerSsl"
end
protocol = ssl ? 'https' : 'http'
"#{protocol}://#{dns_name}"
end
|