Class: Inventory::Elb
- Inherits:
-
Base
- Object
- Base
- Inventory::Elb
show all
- Defined in:
- lib/inventory/elb.rb
Instance Method Summary
collapse
Methods inherited from Base
eager_load!, inherited, #initialize, #report, #show, subclasses, #test_mode
#acm, #cfn, #cw, #eb, #ec2, #ecs, #elbv1, #elbv2, #iam, #pricing, #rds, #route53
Methods included from Shared
#instances, #security_groups
Instance Method Details
#application_load_balancers ⇒ Object
58
59
60
|
# File 'lib/inventory/elb.rb', line 58
def application_load_balancers
@application_load_balancers ||= elbv2.describe_load_balancers.load_balancers
end
|
#classic_load_balancers ⇒ Object
38
39
40
|
# File 'lib/inventory/elb.rb', line 38
def classic_load_balancers
@classic_load_balancers ||= elbv1.describe_load_balancers.load_balancer_descriptions
end
|
#data ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/inventory/elb.rb', line 6
def data
data = []
elbs.each do |lb|
lb.security_groups.each do |group_id|
security_group_name = security_group_name(group_id) open_ports = open_ports(group_id)
data << [
lb.load_balancer_name,
lb_type(lb),
security_group_name,
open_ports]
end
end
data
end
|
#elbs ⇒ Object
29
30
31
|
# File 'lib/inventory/elb.rb', line 29
def elbs
application_load_balancers + classic_load_balancers
end
|
2
3
4
|
# File 'lib/inventory/elb.rb', line 2
def
["ELB", "Type", "Security Group", "Open Ports"]
end
|
#lb_type(lb) ⇒ Object
25
26
27
|
# File 'lib/inventory/elb.rb', line 25
def lb_type(lb)
lb.respond_to?(:type) ? lb.type : 'classic'
end
|
#open_ports(group_id) ⇒ Object
Returns an Array of ports with a cidr of 0.0.0.0/0 Delegates to Inventory::SecurityGroup
64
65
66
67
68
69
70
|
# File 'lib/inventory/elb.rb', line 64
def open_ports(group_id)
sg = security_groups.find { |sg| sg.group_id == group_id }
return unless sg
inventory = Inventory::SecurityGroup::Open.new(@options)
inventory.ports_open_to_world(sg)
end
|
#security_group_name(group_id) ⇒ Object
Somehow sometimes there can be an ELB with a security group that does not actually exist. In the AWS Console it says:
"There was an error loading the Security Groups."
52
53
54
55
56
|
# File 'lib/inventory/elb.rb', line 52
def security_group_name(group_id)
security_group = security_groups.find { |sg| sg.group_id == group_id }
group_name = security_group ? security_group.group_name : "not found"
"#{group_id} (#{group_name})"
end
|
#security_group_names(lb) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/inventory/elb.rb', line 42
def security_group_names(lb)
lb.security_groups.map do |group_id|
security_group_name(group_id)
end.join(', ')
end
|
#sort(data) ⇒ Object
34
35
36
|
# File 'lib/inventory/elb.rb', line 34
def sort(data)
data
end
|