Class: Ufo::Info
Instance Attribute Summary
Attributes inherited from CLI::Base
#task_definition
Instance Method Summary
collapse
#acm, #applicationautoscaling, #aws_options, #cfn, #cloudwatchlogs, #ec2, #ecr, #ecs, #elb, #s3, #ssm_client, #waf_client
#find_stack, #find_stack_resources, #status, #task_definition_arns
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
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/ufo/info.rb', line 22
def load_balancer(service)
load_balancer = service.load_balancers.first
return unless load_balancer
begin
resp = elb.describe_target_groups(
target_group_arns: [load_balancer.target_group_arn]
)
rescue Aws::ElasticLoadBalancingV2::Errors::TargetGroupNotFound
return
end
target_group = resp.target_groups.first
load_balancer_arn = target_group.load_balancer_arns.first return unless load_balancer_arn
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
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/ufo/info.rb', line 47
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
59
60
61
|
# File 'lib/ufo/info.rb', line 59
def service?
!!service
end
|
#stack ⇒ Object
63
64
65
|
# File 'lib/ufo/info.rb', line 63
def stack
find_stack(@stack_name)
end
|
#stack_resources ⇒ Object
85
86
87
88
|
# File 'lib/ufo/info.rb', line 85
def stack_resources
resp = cfn.describe_stack_resources(stack_name: @stack_name)
resp.stack_resources
end
|
#url ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/ufo/info.rb', line 68
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
|