Deploy an Amazon VPC

Overview

A configuration package to deploy an Amazon VPC with predefined presets to select: Subnet Tiers (Public and Private), Availability Zones, and Internet Connectivity. Configuration includes Subnets, Routing Tables, Internet Gateway, Nat Gateways, Security Groups, VPC Endpoints, and VPC Flow Logs.

Configure & Deploy

Configuration Presets

  • Create two subnet tiers: public and private
  • Each subnet tier will contain 2 subnets (using the first 2 AZs of the region)
  • Provisions an Internet Gateway (IGW) attached to the VPC
  • Provisions a single Nat Gateway (Cost Savings Option but not recommended for Production)
  • Allows direct inbound and outbound internet connectivity to the public subnet tier through the IGW
  • Allows outbound-only internet connectivity to the private subnet tier through the NAT Gateway
  • Do not enable VPC Flow Logs

Configuration Template

EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
EDIT
Items
19
Size
4.0 KB
AWSTemplateFormatVersion: '2010-09-09'
Description: ''
Resources:
  VPC:
    Type: 'AWS::EC2::VPC'
    Properties:
      CidrBlock: 10.0.0.0/16
      EnableDnsHostnames: true
      EnableDnsSupport: true
  PublicSubnet1:
    Type: 'AWS::EC2::Subnet'
    Properties:
      CidrBlock: 10.0.0.0/24
      MapPublicIpOnLaunch: false
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Public Subnet AZ A
      AvailabilityZone:
        'Fn::Select':
          - '0'
          - 'Fn::GetAZs':
              Ref: 'AWS::Region'
  PublicSubnet2:
    Type: 'AWS::EC2::Subnet'
    Properties:
      CidrBlock: 10.0.1.0/24
      MapPublicIpOnLaunch: false
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Public Subnet AZ B
      AvailabilityZone:
        'Fn::Select':
          - '1'
          - 'Fn::GetAZs':
              Ref: 'AWS::Region'
  PrivateSubnet1:
    Type: 'AWS::EC2::Subnet'
    Properties:
      CidrBlock: 10.0.10.0/24
      MapPublicIpOnLaunch: false
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Private Subnet AZ A
      AvailabilityZone:
        'Fn::Select':
          - '0'
          - 'Fn::GetAZs':
              Ref: 'AWS::Region'
  PrivateSubnet2:
    Type: 'AWS::EC2::Subnet'
    Properties:
      CidrBlock: 10.0.11.0/24
      MapPublicIpOnLaunch: false
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Private Subnet AZ B
      AvailabilityZone:
        'Fn::Select':
          - '1'
          - 'Fn::GetAZs':
              Ref: 'AWS::Region'
  RouteTablePublic:
    Type: 'AWS::EC2::RouteTable'
    Properties:
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Public Route Table
  RouteTablePublicAssociation1:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      RouteTableId:
        Ref: RouteTablePublic
      SubnetId:
        Ref: PublicSubnet1
  RouteTablePublicAssociation2:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      RouteTableId:
        Ref: RouteTablePublic
      SubnetId:
        Ref: PublicSubnet2
  RouteTablePublicRoute0:
    Type: 'AWS::EC2::Route'
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      RouteTableId:
        Ref: RouteTablePublic
      GatewayId:
        Ref: Igw
  RouteTablePrivate1:
    Type: 'AWS::EC2::RouteTable'
    Properties:
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Private Route Table A
  RouteTablePrivate1Association1:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      RouteTableId:
        Ref: RouteTablePrivate1
      SubnetId:
        Ref: PrivateSubnet1
  RouteTablePrivate1Route0:
    Type: 'AWS::EC2::Route'
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      RouteTableId:
        Ref: RouteTablePrivate1
      NatGatewayId:
        Ref: NatGw1
  RouteTablePrivate2:
    Type: 'AWS::EC2::RouteTable'
    Properties:
      VpcId:
        Ref: VPC
      Tags:
        - Key: Name
          Value: Private Route Table B
  RouteTablePrivate2Association1:
    Type: 'AWS::EC2::SubnetRouteTableAssociation'
    Properties:
      RouteTableId:
        Ref: RouteTablePrivate2
      SubnetId:
        Ref: PrivateSubnet2
  RouteTablePrivate2Route0:
    Type: 'AWS::EC2::Route'
    Properties:
      DestinationCidrBlock: 0.0.0.0/0
      RouteTableId:
        Ref: RouteTablePrivate2
      NatGatewayId:
        Ref: NatGw1
  Igw:
    Type: 'AWS::EC2::InternetGateway'
    Properties: {}
  IGWAttachment:
    Type: 'AWS::EC2::VPCGatewayAttachment'
    Properties:
      VpcId:
        Ref: VPC
      InternetGatewayId:
        Ref: Igw
  NatGw1:
    Type: 'AWS::EC2::NatGateway'
    Properties:
      SubnetId:
        Ref: PublicSubnet1
      AllocationId:
        'Fn::GetAtt':
          - NatGw1ElasticIP
          - AllocationId
      Tags:
        - Key: Name
          Value: NAT GW A
  NatGw1ElasticIP:
    Type: 'AWS::EC2::EIP'
    Properties:
      Domain: vpc
Parameters: {}
Metadata: {}
Conditions: {}