Skip to content

Instantly share code, notes, and snippets.

@lvthillo
Created February 27, 2019 18:17
Show Gist options
  • Save lvthillo/f8e4809172ca61df7c5cc5e60c892b3c to your computer and use it in GitHub Desktop.
Save lvthillo/f8e4809172ca61df7c5cc5e60c892b3c to your computer and use it in GitHub Desktop.
Subnets
Parameters:
Region:
Type: String
Default: eu-west-1
AllowedValues:
- eu-west-1
- eu-west-2
- eu-west-3
- eu-central-1
- us-west-2
- us-west-1
- us-east-2
- us-east-1
- ap-south-1
- ap-northeast-2
- ap-northeast-1
- ap-southeast-2
- ap-southeast-1
- ca-central-1
- sa-east-1
Description: Enter the AWS region to deploy stack. Default is eu-west-1
PublicSubnet1Cidr:
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}/\d{1,2}'
Type: String
Default: 10.0.1.0/24
Description: Enter the CIDR for your Public Subnet 1
PublicSubnet2Cidr:
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}/\d{1,2}'
Type: String
Default: 10.0.2.0/24
Description: Enter the CIDR for your Public Subnet 2
PrivateSubnet1Cidr:
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}/\d{1,2}'
Type: String
Default: 10.0.3.0/24
Description: Enter the CIDR for your Private Subnet 1
PrivateSubnet2Cidr:
AllowedPattern: '((\d{1,3})\.){3}\d{1,3}/\d{1,2}'
Type: String
Default: 10.0.4.0/24
Description: Enter the CIDR for your Private Subnet 2
...
Resources:
PublicSubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Sub ${Region}a
CidrBlock: !Ref PublicSubnet1Cidr
VpcId: !Ref VPC
Tags:
- Key: Name
Value: PublicSubnet-1
PublicSubnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Sub ${Region}b
CidrBlock: !Ref PublicSubnet2Cidr
VpcId: !Ref VPC
Tags:
- Key: Name
Value: PublicSubnet-2
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Sub ${Region}a
CidrBlock: !Ref PrivateSubnet1Cidr
VpcId: !Ref VPC
Tags:
- Key: Name
Value: PrivateSubnet-1
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: !Sub ${Region}b
CidrBlock: !Ref PrivateSubnet2Cidr
VpcId: !Ref VPC
Tags:
- Key: Name
Value: PrivateSubnet-2
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment