Sha256: 337ce0cacbe67fed4a5657743b903a39983f3f6ab3a928b2a063a493434ad9c1

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require 'cfndsl'

CloudFormation do
  Description 'Creates an AWS VPC with a couple of subnets.'

  VPC(:VPC) do
    EnableDnsSupport true
    EnableDnsHostnames true
    CidrBlock '10.1.0.0/16'
    add_tag('Name', 'Test VPC')
  end

  InternetGateway(:InternetGateway) do
    add_tag('Name', 'Test VPC Gateway')
  end

  VPCGatewayAttachment(:GatewayToInternet) do
    VpcId Ref(:VPC)
    InternetGatewayId Ref(:InternetGateway)
  end

  10.times do |i|
    subnet = "subnet#{i}"
    route_table = "#{subnet}RouteTable"
    route_table_assoc = "#{route_table}Assoc"

    Subnet(subnet) do
      VpcId Ref(:VPC)
      CidrBlock "10.1.#{i}.0/24"
      add_tag('Name', "test vpc #{subnet}")
    end

    RouteTable(route_table) do
      VpcId Ref(:VPC)
      add_tag('Name', route_table)
    end

    SubnetRouteTableAssociation(route_table_assoc) do
      SubnetId Ref(subnet)
      RouteTableId Ref(route_table)
    end

    EC2_Route("#{subnet}GatewayRoute") do
      DependsOn :GatewayToInternet
      RouteTableId Ref(route_table)
      DestinationCidrBlock '0.0.0.0/0'
      GatewayId Ref(:InternetGateway)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cfndsl-1.7.2 sample/vpc_example.rb
cfndsl-1.6.0 sample/vpc_example.rb
cfndsl-1.5.0 sample/vpc_example.rb
cfndsl-1.4.0 sample/vpc_example.rb
cfndsl-1.3.9 sample/vpc_example.rb
cfndsl-1.3.8 sample/vpc_example.rb
cfndsl-1.3.7 sample/vpc_example.rb
cfndsl-1.3.6 sample/vpc_example.rb
cfndsl-1.3.5 sample/vpc_example.rb
cfndsl-1.3.4 sample/vpc_example.rb
cfndsl-1.3.3 sample/vpc_example.rb
cfndsl-1.3.2 sample/vpc_example.rb
cfndsl-1.3.1 sample/vpc_example.rb
cfndsl-1.3.0 sample/vpc_example.rb