class Terraforming::Resource::Subnet
Public Class Methods
new(client)
click to toggle source
# File lib/terraforming/resource/subnet.rb, line 14 def initialize(client) @client = client end
tf(client: Aws::EC2::Client.new)
click to toggle source
# 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)
click to toggle source
# File lib/terraforming/resource/subnet.rb, line 10 def self.tfstate(client: Aws::EC2::Client.new) self.new(client).tfstate end
Public Instance Methods
tf()
click to toggle source
# File lib/terraforming/resource/subnet.rb, line 18 def tf apply_template(@client, "tf/subnet") end
tfstate()
click to toggle source
# 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
Private Instance Methods
module_name_of(subnet)
click to toggle source
# File lib/terraforming/resource/subnet.rb, line 50 def module_name_of(subnet) normalize_module_name("#{subnet.subnet_id}-#{name_from_tag(subnet, subnet.subnet_id)}") end
subnets()
click to toggle source
# File lib/terraforming/resource/subnet.rb, line 46 def subnets @client.describe_subnets.map(&:subnets).flatten end