Class: Terraforming::Resource::Subnet
- Inherits:
-
Object
- Object
- Terraforming::Resource::Subnet
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/subnet.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) ⇒ Subnet
Returns a new instance of Subnet.
14
15
16
|
# File 'lib/terraforming/resource/subnet.rb', line 14
def initialize(client)
@client = client
end
|
Class Method Details
.tf(client: Aws::EC2::Client.new) ⇒ Object
6
7
8
|
# File 'lib/terraforming/resource/subnet.rb', line 6
def self.tf(client: Aws::EC2::Client.new)
self.new(client).tf
end
|
.tfstate(client: Aws::EC2::Client.new) ⇒ Object
10
11
12
|
# File 'lib/terraforming/resource/subnet.rb', line 10
def self.tfstate(client: Aws::EC2::Client.new)
self.new(client).tfstate
end
|
Instance Method Details
#tf ⇒ Object
18
19
20
|
# File 'lib/terraforming/resource/subnet.rb', line 18
def tf
apply_template(@client, "tf/subnet")
end
|
#tfstate ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/terraforming/resource/subnet.rb', line 22
def tfstate
subnets.inject({}) do |resources, subnet|
attributes = {
"availability_zone" => subnet.availability_zone,
"cidr_block" => subnet.cidr_block,
"id" => subnet.subnet_id,
"map_public_ip_on_launch" => subnet.map_public_ip_on_launch.to_s,
"tags.#" => subnet.tags.length.to_s,
"vpc_id" => subnet.vpc_id,
}
resources["aws_subnet.#{module_name_of(subnet)}"] = {
"type" => "aws_subnet",
"primary" => {
"id" => subnet.subnet_id,
"attributes" => attributes
}
}
resources
end
end
|