lib/terraforming/resource/elb.rb in terraforming-0.9.1 vs lib/terraforming/resource/elb.rb in terraforming-0.10.0
- old
+ new
@@ -46,11 +46,10 @@
attributes.merge!(sg_attributes_of(load_balancer))
attributes.merge!(subnets_attributes_of(load_balancer))
attributes.merge!(instances_attributes_of(load_balancer))
attributes.merge!(tags_attributes_of(load_balancer))
-
resources["aws_elb.#{module_name_of(load_balancer)}"] = {
"type" => "aws_elb",
"primary" => {
"id" => load_balancer.load_balancer_name,
"attributes" => attributes
@@ -104,51 +103,51 @@
Zlib.crc32(string)
end
def tags_attributes_of(elb)
tags = @client.describe_tags(load_balancer_names: [elb.load_balancer_name]).tag_descriptions.first.tags
- attributes = {"tags.#" => tags.length.to_s}
+ attributes = { "tags.#" => tags.length.to_s }
tags.each do |tag|
attributes["tags.#{tag.key}"] = tag.value
end
attributes
end
def instances_attributes_of(elb)
- attributes = {"instances.#" => elb.instances.length.to_s}
+ attributes = { "instances.#" => elb.instances.length.to_s }
elb.instances.each do |instance|
attributes["instances.#{Zlib.crc32(instance.instance_id)}"] = instance.instance_id
end
attributes
end
def subnets_attributes_of(elb)
- attributes = {"subnets.#" => elb.subnets.length.to_s}
+ attributes = { "subnets.#" => elb.subnets.length.to_s }
elb.subnets.each do |subnet_id|
attributes["subnets.#{Zlib.crc32(subnet_id)}"] = subnet_id
end
attributes
end
def sg_attributes_of(elb)
- attributes = {"security_groups.#" => elb.security_groups.length.to_s}
+ attributes = { "security_groups.#" => elb.security_groups.length.to_s }
elb.security_groups.each do |sg_id|
attributes["security_groups.#{Zlib.crc32(sg_id)}"] = sg_id
end
attributes
end
def listeners_attributes_of(elb)
- attributes = {"listener.#" => elb.listener_descriptions.length.to_s}
+ attributes = { "listener.#" => elb.listener_descriptions.length.to_s }
elb.listener_descriptions.each do |listener_description|
attributes.merge!(listener_attributes_of(listener_description.listener))
end
@@ -179,10 +178,10 @@
Zlib.crc32(string)
end
def load_balancers
- @client.describe_load_balancers.load_balancer_descriptions
+ @client.describe_load_balancers.map(&:load_balancer_descriptions).flatten
end
def load_balancer_attributes_of(load_balancer)
@client.describe_load_balancer_attributes(load_balancer_name: load_balancer.load_balancer_name).load_balancer_attributes
end