Method: Awspec::Generator::Spec::Subnet#generate_by_vpc_id

Defined in:
lib/awspec/generator/spec/subnet.rb

#generate_by_vpc_id(vpc_id) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/awspec/generator/spec/subnet.rb', line 5

def generate_by_vpc_id(vpc_id)
  describes = %w(
    subnet_id cidr_block
  )
  vpc = find_vpc(vpc_id)
  raise 'Not Found VPC' unless vpc
  @vpc_id = vpc[:vpc_id]
  @vpc_tag_name = vpc.tag_name
  subnets = select_subnet_by_vpc_id(@vpc_id)
  specs = subnets.map do |subnet|
    subnet_id = subnet[:subnet_id]
    subnet_tag_name = subnet.tag_name
    content = ERB.new(subnet_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
  end
  specs.join("\n")
end