Class: Terraforming::Resource::ALB
- Inherits:
-
Object
- Object
- Terraforming::Resource::ALB
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/alb.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
#apply_template, #name_from_tag, #normalize_module_name, #prettify_policy, #template_path
Constructor Details
#initialize(client) ⇒ ALB
Returns a new instance of ALB.
14
15
16
|
# File 'lib/terraforming/resource/alb.rb', line 14
def initialize(client)
@client = client
end
|
Class Method Details
.tf(client: Aws::ElasticLoadBalancingV2::Client.new) ⇒ Object
6
7
8
|
# File 'lib/terraforming/resource/alb.rb', line 6
def self.tf(client: Aws::ElasticLoadBalancingV2::Client.new)
self.new(client).tf
end
|
.tfstate(client: Aws::ElasticLoadBalancingV2::Client.new) ⇒ Object
10
11
12
|
# File 'lib/terraforming/resource/alb.rb', line 10
def self.tfstate(client: Aws::ElasticLoadBalancingV2::Client.new)
self.new(client).tfstate
end
|
Instance Method Details
#tf ⇒ Object
18
19
20
|
# File 'lib/terraforming/resource/alb.rb', line 18
def tf
apply_template(@client, "tf/alb")
end
|
#tfstate ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/terraforming/resource/alb.rb', line 22
def tfstate
load_balancers.inject({}) do |resources, load_balancer|
load_balancer_attributes = load_balancer_attributes_of(load_balancer)
attributes = {
"dns_name" => load_balancer.dns_name,
"enable_deletion_protection" => load_balancer_attributes["deletion_protection.enabled"].to_s,
"id" => load_balancer.load_balancer_arn,
"idle_timeout" => load_balancer_attributes["idle_timeout.timeout_seconds"].to_s,
"internal" => internal?(load_balancer).to_s,
"name" => load_balancer.load_balancer_name,
"security_groups.#" => load_balancer.security_groups.length.to_s,
"subnets.#" => load_balancer.availability_zones.length.to_s,
"zone_id" => load_balancer.canonical_hosted_zone_id,
}
attributes.merge!(access_logs_attributes_of(load_balancer_attributes))
attributes.merge!(tag_attributes_of(load_balancer))
resources["aws_alb.#{module_name_of(load_balancer)}"] = {
"type" => "aws_alb",
"primary" => {
"id" => load_balancer.load_balancer_arn,
"attributes" => attributes
}
}
resources
end
end
|