CloudFormation template
From MyWiki
{ "Description": "Building on AWS VPC", "Mappings": { "AWSRegionToAMI": { "us-west-2": { "AMI": "ami-32cf7b4a" } } }, "Resources": { "VPC": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.1.0.0/16", "Tags": [ { "Key": "Name", "Value": "edx-build-aws-vpc" } ] } }, "InternetGateway": { "Type": "AWS::EC2::InternetGateway", "Properties": { "Tags": [ { "Key": "Name", "Value": "edx-igw" } ] } }, "AttachGateway": { "Type": "AWS::EC2::VPCGatewayAttachment", "Properties": { "VpcId": { "Ref": "VPC" }, "InternetGatewayId": { "Ref": "InternetGateway" } } }, "PublicSubnet1": { "Type": "AWS::EC2::Subnet", "Properties": { "AvailabilityZone": { "Fn::Select": [ "0", { "Fn::GetAZs": "" } ] }, "CidrBlock": "10.1.1.0/24", "VpcId": { "Ref": "VPC" }, "MapPublicIpOnLaunch": "true", "Tags": [ { "Key": "Name", "Value": "edx-subnet-public-a" } ] } }, "PublicSubnet2": { "Type": "AWS::EC2::Subnet", "Properties": { "AvailabilityZone": { "Fn::Select": [ "1", { "Fn::GetAZs": "" } ] }, "CidrBlock": "10.1.2.0/24", "VpcId": { "Ref": "VPC" }, "MapPublicIpOnLaunch": "true", "Tags": [ { "Key": "Name", "Value": "edx-subnet-public-b" } ] } }, "PublicRouteTable": { "Type": "AWS::EC2::RouteTable", "Properties": { "VpcId": { "Ref": "VPC" }, "Tags": [ { "Key": "Name", "Value": "edx-routetable-public" } ] } }, "PublicDefaultRoute": { "Type": "AWS::EC2::Route", "DependsOn": "AttachGateway", "Properties": { "DestinationCidrBlock": "0.0.0.0/0", "GatewayId": { "Ref": "InternetGateway" }, "RouteTableId": { "Ref": "PublicRouteTable" } } }, "PublicRouteAssociation1": { "Type": "AWS::EC2::SubnetRouteTableAssociation", "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "SubnetId": { "Ref": "PublicSubnet1" } } }, "PublicRouteAssociation2": { "Type": "AWS::EC2::SubnetRouteTableAssociation", "Properties": { "RouteTableId": { "Ref": "PublicRouteTable" }, "SubnetId": { "Ref": "PublicSubnet2" } } }, "PrivateSubnet1": { "Type": "AWS::EC2::Subnet", "Properties": { "AvailabilityZone": { "Fn::Select": [ "0", { "Fn::GetAZs": "" } ] }, "CidrBlock": "10.1.3.0/24", "VpcId": { "Ref": "VPC" }, "Tags": [ { "Key": "Name", "Value": "edx-subnet-private-a" } ] } }, "PrivateSubnet2": { "Type": "AWS::EC2::Subnet", "Properties": { "AvailabilityZone": { "Fn::Select": [ "1", { "Fn::GetAZs": "" } ] }, "CidrBlock": "10.1.4.0/24", "VpcId": { "Ref": "VPC" }, "Tags": [ { "Key": "Name", "Value": "edx-subnet-private-b" } ] } } }, "Outputs": { "PublicSubnet1" : { "Description" : "Public Subnet 1", "Value" : { "Ref": "PublicSubnet1" } }, "PublicSubnet2" : { "Description" : "Public Subnet 2", "Value" : { "Ref": "PublicSubnet2" } }, "PrivateSubnet1" : { "Description" : "Private Subnet 1", "Value" : { "Ref": "PrivateSubnet1" } }, "PrivateSubnet2" : { "Description" : "Private Subnet 2", "Value" : { "Ref": "PrivateSubnet2" } }, } }