Sha256: 6a6b30db1b6484b4f2573164b4a1a9b1d84de420c594597d5b2b52956449575b

Contents?: true

Size: 1.13 KB

Versions: 11

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

11 entries across 11 versions & 1 rubygems

Version Path
cfndsl-1.2.0 sample/vpc_example.rb
cfndsl-1.1.1 sample/vpc_example.rb
cfndsl-1.1.0 sample/vpc_example.rb
cfndsl-1.0.6 sample/vpc_example.rb
cfndsl-1.0.5 sample/vpc_example.rb
cfndsl-1.0.4 sample/vpc_example.rb
cfndsl-1.0.3 sample/vpc_example.rb
cfndsl-1.0.2 sample/vpc_example.rb
cfndsl-1.0.1 sample/vpc_example.rb
cfndsl-1.0.0 sample/vpc_example.rb
cfndsl-1.0.0.pre.1 sample/vpc_example.rb