Created
April 17, 2013 15:22
-
-
Save aporat/5405198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "Build an AWS VPC with 2 subnets in a single AZ. **WARNING** You will be billed for the AWS resources used if you create a stack from this template.", | |
"Parameters" : { | |
"KeyName" : { | |
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances", | |
"Type" : "String", | |
"MinLength": "1", | |
"MaxLength": "64", | |
"AllowedPattern" : "[-_ a-zA-Z0-9]*", | |
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores." | |
} | |
}, | |
"Mappings" : { | |
"AWSInstanceType2Arch" : { | |
"t1.micro" : { "Arch" : "64" }, | |
"m1.small" : { "Arch" : "64" }, | |
"m1.medium" : { "Arch" : "64" }, | |
"m1.large" : { "Arch" : "64" }, | |
"m1.xlarge" : { "Arch" : "64" }, | |
"m2.xlarge" : { "Arch" : "64" }, | |
"m2.2xlarge" : { "Arch" : "64" }, | |
"m2.4xlarge" : { "Arch" : "64" }, | |
"c1.medium" : { "Arch" : "64" }, | |
"c1.xlarge" : { "Arch" : "64" } | |
}, | |
"AWSRegionArch2AMINAT" : { | |
"us-east-1" : { "64" : "ami-f619c29f" }, | |
"us-west-1" : { "64" : "ami-3bcc9e7e" }, | |
"us-west-2" : { "64" : "ami-52ff7262" }, | |
"eu-west-1" : { "64" : "ami-e5e2d991" }, | |
"sa-east-1" : { "64" : "ami-0039e61d" }, | |
"ap-southeast-1" : { "64" : "ami-02eb9350" }, | |
"ap-northeast-1" : { "64" : "ami-14d86d15" } | |
} | |
}, | |
"Resources" : { | |
"VPC" : { | |
"Type" : "AWS::EC2::VPC", | |
"Properties" : { | |
"CidrBlock" : "192.168.0.0/16", | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Public" } | |
] | |
} | |
}, | |
"PublicSubnet" : { | |
"Type" : "AWS::EC2::Subnet", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"CidrBlock" : "192.168.1.0/24", | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Public" } | |
] | |
} | |
}, | |
"InternetGateway" : { | |
"Type" : "AWS::EC2::InternetGateway", | |
"Properties" : { | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Public" } | |
] | |
} | |
}, | |
"AttachGateway" : { | |
"Type" : "AWS::EC2::VPCGatewayAttachment", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"InternetGatewayId" : { "Ref" : "InternetGateway" } | |
} | |
}, | |
"PublicRouteTable" : { | |
"Type" : "AWS::EC2::RouteTable", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Public" } | |
] | |
} | |
}, | |
"PublicRoute" : { | |
"Type" : "AWS::EC2::Route", | |
"Properties" : { | |
"RouteTableId" : { "Ref" : "PublicRouteTable" }, | |
"DestinationCidrBlock" : "0.0.0.0/0", | |
"GatewayId" : { "Ref" : "InternetGateway" } | |
} | |
}, | |
"PublicSubnetRouteTableAssociation" : { | |
"Type" : "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PublicSubnet" }, | |
"RouteTableId" : { "Ref" : "PublicRouteTable" } | |
} | |
}, | |
"PrivateSubnet" : { | |
"Type" : "AWS::EC2::Subnet", | |
"Properties" : { | |
"VpcId" : { "Ref" : "VPC" }, | |
"CidrBlock" : "192.168.10.0/24", | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Private" } | |
] | |
} | |
}, | |
"PrivateRouteTable" : { | |
"Type" : "AWS::EC2::RouteTable", | |
"Properties" : { | |
"VpcId" : {"Ref" : "VPC"}, | |
"Tags" : [ | |
{"Key" : "Application", "Value" : { "Ref" : "AWS::StackName"} }, | |
{"Key" : "Network", "Value" : "Private" } | |
] | |
} | |
}, | |
"PrivateSubnetRouteTableAssociation" : { | |
"Type" : "AWS::EC2::SubnetRouteTableAssociation", | |
"Properties" : { | |
"SubnetId" : { "Ref" : "PrivateSubnet" }, | |
"RouteTableId" : { "Ref" : "PrivateRouteTable" } | |
} | |
}, | |
"PrivateRoute" : { | |
"Type" : "AWS::EC2::Route", | |
"Properties" : { | |
"RouteTableId" : { "Ref" : "PrivateRouteTable" }, | |
"DestinationCidrBlock" : "0.0.0.0/0", | |
"InstanceId" : { "Ref" : "NATDevice" } | |
} | |
}, | |
"NATIPAddress" : { | |
"Type" : "AWS::EC2::EIP", | |
"Properties" : { | |
"Domain" : "vpc", | |
"InstanceId" : { "Ref" : "NATDevice" } | |
} | |
}, | |
"NATDevice" : { | |
"Type" : "AWS::EC2::Instance", | |
"Properties" : { | |
"InstanceType" : "m1.small", | |
"KeyName" : { "Ref" : "KeyName" }, | |
"SubnetId" : { "Ref" : "PublicSubnet" }, | |
"SourceDestCheck" : "false", | |
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMINAT", { "Ref" : "AWS::Region" }, "64" ]}, | |
"SecurityGroupIds" : [{ "Ref" : "NATSecurityGroup" }] | |
} | |
}, | |
"NATSecurityGroup" : { | |
"Type" : "AWS::EC2::SecurityGroup", | |
"Properties" : { | |
"GroupDescription" : "Enable internal access to the NAT device", | |
"VpcId" : { "Ref" : "VPC" }, | |
"SecurityGroupIngress" : [ | |
{ "IpProtocol" : "tcp", "FromPort" : "0", "ToPort" : "65535", "CidrIp" : "192.168.0.0/16" } , | |
{ "IpProtocol" : "udp", "FromPort" : "0", "ToPort" : "65535", "CidrIp" : "192.168.0.0/16" } , | |
{ "IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "192.168.0.0/16" } | |
], | |
"SecurityGroupEgress" : [ | |
{ "IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0" } , | |
{ "IpProtocol" : "tcp", "FromPort" : "443", "ToPort" : "443", "CidrIp" : "0.0.0.0/0" }, | |
{ "IpProtocol" : "tcp", "FromPort" : "0", "ToPort" : "65535", "CidrIp" : "192.168.0.0/16" }, | |
{ "IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0" } | |
] | |
} | |
} | |
}, | |
"Outputs" : { | |
"VpcId" : { | |
"Value" : {"Ref" : "VPC"}, | |
"Description" : "VPC ID of newly created VPC" | |
}, | |
"PublicSubnetID" : { | |
"Value" : {"Ref" : "PublicSubnet"}, | |
"Description" : "Public subnet ID" | |
}, | |
"PrivateSubnetID" : { | |
"Value" : {"Ref": "PrivateSubnet"}, | |
"Description" : "Private Subnet ID" | |
}, | |
"InstanceID" : { | |
"Value" : {"Ref": "NATDevice"}, | |
"Description" : "NAT Instance ID" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment