Class: Awful::Alb
Constant Summary
collapse
- COLORS =
{
active: :green,
provisioning: :yellow,
failed: :red,
healthy: :green,
unhealthy: :red,
InService: :green,
OutOfService: :red,
}
Instance Method Summary
collapse
Methods inherited from Cli
#initialize, #ll, #version
Constructor Details
This class inherits a constructor from Awful::Cli
Instance Method Details
#dump(*names) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/awful/alb.rb', line 80
def dump(*names)
describe_load_balancers(*names).output do |albs|
albs.each do |alb|
puts YAML.dump(stringify_keys(alb.to_hash))
end
end
end
|
#instances(name) ⇒ Object
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/awful/alb.rb', line 118
def instances(name)
alb.describe_target_groups(load_balancer_arn: get_arn(name)).target_groups.map do |tg|
alb.describe_target_health(target_group_arn: tg.target_group_arn).target_health_descriptions
end.flatten(1).output do |targets|
if options[:long]
print_table targets.map { |t|
[t.target.id, t.target.port, color(t.target_health.state), t.target_health.reason, t.target_health.description]
}
else
puts targets.map{ |t| t.target.id }
end
end
end
|
#listeners(name) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/awful/alb.rb', line 90
def listeners(name)
alb.describe_listeners(load_balancer_arn: get_arn(name)).listeners.output do |listeners|
if options[:long]
print_table listeners.map { |l|
[l.protocol, l.port, l.ssl_policy, l.certificates.join(','), l.listener_arn]
}.sort
else
puts listeners.map(&:listener_arn)
end
end
end
|
#ls(*names) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/awful/alb.rb', line 67
def ls(*names)
describe_load_balancers(*names).tap do |albs|
albs.select! { |a| a.load_balancer_name.match(options[:matching]) } if options[:matching]
end.output do |list|
if options[:long]
print_table list.map { |a| [a.load_balancer_name, a.dns_name, color(a.state.code), a.vpc_id, a.created_time] }
else
puts list.map(&:load_balancer_name)
end
end
end
|
#rules(listener) ⇒ Object
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/awful/alb.rb', line 134
def rules(listener)
alb.describe_rules(listener_arn: listener).rules.output do |rules|
if options[:long]
print_table rules.map { |r|
[r.priority, r.rule_arn]
}
else
puts rules.map(&:rule_arn)
end
end
end
|
#tag(name, key, value = nil) ⇒ Object
157
158
159
160
161
162
163
164
165
|
# File 'lib/awful/alb.rb', line 157
def tag(name, key, value = nil)
if options[:delete]
remove_tags(name, key)
elsif value
add_tag(name, key, value)
else
get_tag(name, key)
end
end
|
147
148
149
150
151
152
153
|
# File 'lib/awful/alb.rb', line 147
def tags(*names)
alb.describe_tags(resource_arns: names.map(&method(:get_arn))).tag_descriptions.output do |albs|
albs.each do |alb|
print_table alb.tags.map{ |t| [t.key, t.value] }
end
end
end
|
#targets(name) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/awful/alb.rb', line 104
def targets(name)
alb.describe_target_groups(load_balancer_arn: get_arn(name)).target_groups.output do |target_groups|
if options[:long]
print_table target_groups.map { |t|
[t.target_group_name, t.port, t.protocol, t.vpc_id]
}
else
puts target_groups.map(&:target_group_name)
end
end
end
|