Class: Terraforming::Resource::VPC
- Inherits:
-
Object
- Object
- Terraforming::Resource::VPC
show all
- Includes:
- Util
- Defined in:
- lib/terraforming/resource/vpc.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) ⇒ VPC
Returns a new instance of VPC.
14
15
16
|
# File 'lib/terraforming/resource/vpc.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/vpc.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/vpc.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/vpc.rb', line 18
def tf
apply_template(@client, "tf/vpc")
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/vpc.rb', line 22
def tfstate
vpcs.inject({}) do |resources, vpc|
attributes = {
"cidr_block" => vpc.cidr_block,
"enable_dns_hostnames" => enable_dns_hostnames?(vpc).to_s,
"enable_dns_support" => enable_dns_support?(vpc).to_s,
"id" => vpc.vpc_id,
"instance_tenancy" => vpc.instance_tenancy,
"tags.#" => vpc.tags.length.to_s,
}
resources["aws_vpc.#{module_name_of(vpc)}"] = {
"type" => "aws_vpc",
"primary" => {
"id" => vpc.vpc_id,
"attributes" => attributes
}
}
resources
end
end
|