-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsimpleVPC
222 lines (222 loc) · 7.35 KB
/
simpleVPC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
{
"Parameters": {
"CIDRRange": {
"Description": "VPCCIDR Range (will be a /16 block)",
"Type": "String",
"Default": "10.251.0.0",
"AllowedValues": ["10.250.0.0","10.251.0.0"]
}
},
"Mappings": {
"VPCRanges": {
"10.250.0.0": {
"PublicSubnetAZ1" : "10.250.0.0/22",
"PublicSubnetAZ2" : "10.250.4.0/22",
"PrivateSubnetAZ1" : "10.250.32.0/21",
"PrivateSubnetAZ2" : "10.250.40.0/21"
},
"10.251.0.0": {
"PublicSubnetAZ1" : "10.251.0.0/22",
"PublicSubnetAZ2" : "10.251.4.0/22",
"PrivateSubnetAZ1" : "10.251.32.0/21",
"PrivateSubnetAZ2" : "10.251.40.0/21"
}
}
},
"Resources": {
"VPCBase": {
"Type": "AWS::EC2::VPC",
"Properties": {
"CidrBlock": { "Fn::Join" : ["", [{ "Ref" : "CIDRRange" }, "/16"]] },
"EnableDnsSupport": "True",
"EnableDnsHostnames": "True",
"Tags": [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-VPC"]] } }
]
}
},
"PublicNetAZ1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": { "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"CidrBlock": { "Fn::FindInMap" : [ "VPCRanges", { "Ref": "CIDRRange"}, "PublicSubnetAZ1"] },
"MapPublicIpOnLaunch": "True",
"Tags": [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PublicAZ1"]] } }
],
"VpcId": { "Ref": "VPCBase" }
}
},
"PublicNetAZ2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": { "Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"CidrBlock": { "Fn::FindInMap" : [ "VPCRanges", { "Ref": "CIDRRange"}, "PublicSubnetAZ2" ] },
"MapPublicIpOnLaunch": "True",
"Tags": [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PublicAZ2"]] } }
],
"VpcId": { "Ref": "VPCBase" }
}
},
"PrivateNetAZ1": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": { "Fn::Select": [ "0", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"CidrBlock": { "Fn::FindInMap" : [ "VPCRanges", { "Ref": "CIDRRange"}, "PrivateSubnetAZ1" ] },
"MapPublicIpOnLaunch": "False",
"Tags": [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PrivateAZ1"]] } },
{ "Key": "Network", "Value": "private" }
],
"VpcId": { "Ref": "VPCBase" }
}
},
"PrivateNetAZ2": {
"Type": "AWS::EC2::Subnet",
"Properties": {
"AvailabilityZone": { "Fn::Select": [ "1", { "Fn::GetAZs": { "Ref": "AWS::Region" } } ] },
"CidrBlock": { "Fn::FindInMap" : [ "VPCRanges", { "Ref": "CIDRRange"}, "PrivateSubnetAZ2" ] },
"MapPublicIpOnLaunch": "False",
"Tags": [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PrivateAZ2"]] } },
{ "Key": "Network", "Value": "private" }
],
"VpcId": { "Ref": "VPCBase" }
}
},
"IGWBase" : {
"Type" : "AWS::EC2::InternetGateway",
"Properties" : {
"Tags" : [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-IGW"]] } }
]
}
},
"VGAIGWBase" : {
"Type" : "AWS::EC2::VPCGatewayAttachment",
"Properties" : {
"InternetGatewayId" : { "Ref" : "IGWBase" },
"VpcId" : { "Ref" : "VPCBase" }
}
},
"RouteTablePublic" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "VPCBase" },
"Tags" : [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PublicRT"]] } }
]
}
},
"RouteTablePrivateAZ1" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "VPCBase" },
"Tags" : [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PrivateAZ1RT"]] } }
]
}
},
"RouteTablePrivateAZ2" : {
"Type" : "AWS::EC2::RouteTable",
"Properties" : {
"VpcId" : { "Ref" : "VPCBase" },
"Tags" : [
{ "Key": "Name", "Value": { "Fn::Join" : ["", [{ "Ref" : "AWS::StackName" }, "-PrivateAZ2RT"]] } }
]
}
},
"RoutePublicDefault" : {
"DependsOn": [ "VGAIGWBase" ],
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "RouteTablePublic" },
"DestinationCidrBlock" : "0.0.0.0/0",
"GatewayId" : { "Ref" : "IGWBase" }
}
},
"RouteAssociationPublicAZ1Default" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PublicNetAZ1"},
"RouteTableId" : { "Ref" : "RouteTablePublic" }
}
},
"RouteAssociationPublicAZ2Default" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PublicNetAZ2"},
"RouteTableId" : { "Ref" : "RouteTablePublic" }
}
},
"RouteAssociationPrivateAZ1Default" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PrivateNetAZ1"},
"RouteTableId" : { "Ref" : "RouteTablePrivateAZ1" }
}
},
"RouteAssociationPrivateAZ2Default" : {
"Type" : "AWS::EC2::SubnetRouteTableAssociation",
"Properties" : {
"SubnetId" : { "Ref" : "PrivateNetAZ2"},
"RouteTableId" : { "Ref" : "RouteTablePrivateAZ2" }
}
},
"NATAZ1" : {
"Type" : "AWS::EC2::NatGateway",
"DependsOn" : "VGAIGWBase",
"Properties" : {
"AllocationId" : { "Fn::GetAtt" : ["EIPNATAZ1", "AllocationId"]},
"SubnetId" : { "Ref" : "PublicNetAZ1"}
}
},
"EIPNATAZ1" : {
"Type" : "AWS::EC2::EIP",
"Properties" : {
"Domain" : "vpc"
}
},
"NATAZ1Route" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "RouteTablePrivateAZ1" },
"DestinationCidrBlock" : "0.0.0.0/0",
"NatGatewayId" : { "Ref" : "NATAZ1" }
}
},
"NATAZ2" : {
"Type" : "AWS::EC2::NatGateway",
"DependsOn" : "VGAIGWBase",
"Properties" : {
"AllocationId" : { "Fn::GetAtt" : ["EIPNATAZ2", "AllocationId"]},
"SubnetId" : { "Ref" : "PublicNetAZ2"}
}
},
"EIPNATAZ2" : {
"Type" : "AWS::EC2::EIP",
"Properties" : {
"Domain" : "vpc"
}
},
"NATAZ2Route" : {
"Type" : "AWS::EC2::Route",
"Properties" : {
"RouteTableId" : { "Ref" : "RouteTablePrivateAZ2" },
"DestinationCidrBlock" : "0.0.0.0/0",
"NatGatewayId" : { "Ref" : "NATAZ2" }
}
}
},
"Outputs": {
"VPCID" : { "Value" : { "Ref" : "VPCBase" } },
"ElasticIP1" : { "Value": { "Ref" : "EIPNATAZ1" } },
"ElasticIP2" : { "Value": { "Ref" : "EIPNATAZ2" } },
"SubnetPublicAZ1" : { "Value" : { "Ref" : "PublicNetAZ1"} },
"SubnetPublicAZ2" : { "Value" : { "Ref" : "PublicNetAZ2"} },
"SubnetPrivateAZ1" : { "Value" : { "Ref" : "PrivateNetAZ1"} },
"SubnetPrivateAZ2" : { "Value" : { "Ref" : "PrivateNetAZ2"} },
"DefaultSG" : { "Value" : { "Fn::GetAtt" : ["VPCBase", "DefaultSecurityGroup"] }}
}
}