-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess-ci-vpc.yaml
190 lines (164 loc) · 4.13 KB
/
access-ci-vpc.yaml
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
---
AWSTemplateFormatVersion: 2010-09-09
Parameters:
Name:
Type: String
VpcCIDR:
Type: String
PublicSubnet1CIDR:
Type: String
PublicSubnet2CIDR:
Type: String
PrivateSubnet1CIDR:
Type: String
PrivateSubnet2CIDR:
Type: String
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: !Ref VpcCIDR
Tags:
- Key: Name
Value: !Ref Name
- Key: WBS
Value: 'ACCESS CONECT 1.4'
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Ref Name
- Key: WBS
Value: 'ACCESS CONECT 1.4'
InternetGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
NATGateway:
Type: AWS::EC2::NatGateway
Properties:
AllocationId:
Fn::GetAtt:
- EIPforNATGW
- AllocationId
SubnetId: !Ref Subnet1
Tags:
- Key: Name
Value: !Ref Name
- Key: WBS
Value: 'ACCESS CONECT 1.4'
EIPforNATGW:
DependsOn: InternetGatewayAttachment
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Tags:
- Key: WBS
Value: 'ACCESS CONECT 1.4'
Subnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs ]
MapPublicIpOnLaunch: true
CidrBlock: !Ref PublicSubnet1CIDR
Tags:
- Key: Name
Value: !Sub ${Name} (Public)
- Key: WBS
Value: 'ACCESS CONECT 1.4'
Subnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 1, !GetAZs ]
MapPublicIpOnLaunch: true
CidrBlock: !Ref PublicSubnet2CIDR
Tags:
- Key: Name
Value: !Sub ${Name} (Public)
- Key: WBS
Value: 'ACCESS CONECT 1.4'
PrivateSubnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 0, !GetAZs ]
MapPublicIpOnLaunch: false
CidrBlock: !Ref PrivateSubnet1CIDR
Tags:
- Key: Name
Value: !Sub ${Name} (Private)
- Key: WBS
Value: 'ACCESS CONECT 1.4'
PrivateSubnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
AvailabilityZone: !Select [ 1, !GetAZs ]
MapPublicIpOnLaunch: false
CidrBlock: !Ref PrivateSubnet2CIDR
Tags:
- Key: Name
Value: !Sub ${Name} (Private)
- Key: WBS
Value: 'ACCESS CONECT 1.4'
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Ref Name
- Key: WBS
Value: 'ACCESS CONECT 1.4'
DefaultRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref RouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
Subnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref RouteTable
SubnetId: !Ref Subnet1
Subnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref RouteTable
SubnetId: !Ref Subnet2
NATRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Ref Name
- Key: WBS
Value: 'ACCESS CONECT 1.4'
NATRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref NATRouteTable
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref NATGateway
PrivateSubnet1RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NATRouteTable
SubnetId: !Ref PrivateSubnet1
PrivateSubnet2RouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref NATRouteTable
SubnetId: !Ref PrivateSubnet2
Outputs:
Subnets:
Value: !Join [ ",", [ !Ref Subnet1, !Ref Subnet2 ] ]
PrivateSubnets:
Value: !Join [ ",", [ !Ref PrivateSubnet1, !Ref PrivateSubnet2 ] ]
VpcId:
Value: !Ref VPC