Last active
July 17, 2018 19:49
-
-
Save moses-gangipogu/dae42d64d34d4bf70f6e728cfb11e719 to your computer and use it in GitHub Desktop.
custom vpc subnet
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
Parameters: | |
EnvironmentName: | |
Description: Enter VPC Name | |
Type: String | |
Default: "defaultName" | |
Resources: | |
PubPrivateVPC: | |
Type: 'AWS::EC2::VPC' | |
Properties: | |
CidrBlock: 10.0.0.0/16 | |
Tags: | |
- Key: Name | |
Value: !Ref EnvironmentName | |
## Add more Public | |
PublicSubnet1: | |
Type: 'AWS::EC2::Subnet' | |
Properties: | |
VpcId: !Ref PubPrivateVPC | |
AvailabilityZone: us-east-1a | |
CidrBlock: 10.0.1.0/24 | |
MapPublicIpOnLaunch: true | |
## Add more Private | |
PrivateSubnet1: | |
Type: 'AWS::EC2::Subnet' | |
Properties: | |
VpcId: !Ref PubPrivateVPC | |
AvailabilityZone: us-east-1a | |
CidrBlock: 10.0.2.0/24 | |
MapPublicIpOnLaunch: false | |
InternetGateway: | |
Type: 'AWS::EC2::InternetGateway' | |
Properties: | |
Tags: | |
- Key: Name | |
Value: !Join [_, [!Ref 'AWS::StackName']] | |
- Key: Network | |
Value: Public | |
GatewayToInternet: | |
Type: 'AWS::EC2::VPCGatewayAttachment' | |
Properties: | |
VpcId: !Ref PubPrivateVPC | |
InternetGatewayId: !Ref InternetGateway | |
PublicRouteTable: | |
Type: 'AWS::EC2::RouteTable' | |
Properties: | |
VpcId: !Ref PubPrivateVPC | |
Tags: | |
- Key: Network | |
Value: Public | |
## Add more Public | |
PublicSubnet1RouteTableAssociation: | |
Type: 'AWS::EC2::SubnetRouteTableAssociation' | |
Properties: | |
SubnetId: !Ref PublicSubnet1 | |
RouteTableId: !Ref PublicRouteTable | |
NatGateway: | |
Type: "AWS::EC2::NatGateway" | |
DependsOn: NatPublicIP | |
Properties: | |
AllocationId: !GetAtt NatPublicIP.AllocationId | |
SubnetId: !Ref PublicSubnet1 | |
NatPublicIP: | |
Type: "AWS::EC2::EIP" | |
DependsOn: PubPrivateVPC | |
Properties: | |
Domain: vpc | |
PrivateRouteTable: | |
Type: 'AWS::EC2::RouteTable' | |
Properties: | |
VpcId: !Ref PubPrivateVPC | |
Tags: | |
- Key: Network | |
Value: Private | |
PrivateRoute: | |
Type: 'AWS::EC2::Route' | |
Properties: | |
RouteTableId: !Ref PrivateRouteTable | |
DestinationCidrBlock: 0.0.0.0/0 | |
NatGatewayId: !Ref NatGateway | |
## Add more Private | |
PrivateSubnet1RouteTableAssociation: | |
Type: 'AWS::EC2::SubnetRouteTableAssociation' | |
Properties: | |
SubnetId: !Ref PrivateSubnet1 | |
RouteTableId: !Ref PrivateRouteTable | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment