-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.yaml
299 lines (269 loc) · 11.1 KB
/
master.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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
Description: >
Deploy Wordpress Cluster - main template.
Parameters:
EnvironmentName:
Description: Environment Name
Type: String
Default: testing
AllowedValues:
- production
- staging
- testing
- development
ConstraintDescription: Selected an existent environment name from the list.
VpcCIDR:
Description: Please enter the IP range (CIDR notation) for this VPC
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.0/24"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PublicSubnet1CIDR:
Description: Please enter the IP range (CIDR notation) for the public subnet in the first Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.0/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PublicSubnet2CIDR:
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.16/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PublicSubnet3CIDR:
Description: Please enter the IP range (CIDR notation) for the public subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.32/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PrivateSubnet1CIDR:
Description: Please enter the IP range (CIDR notation) for the private subnet in the first Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.48/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PrivateSubnet2CIDR:
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.64/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
PrivateSubnet3CIDR:
Description: Please enter the IP range (CIDR notation) for the private subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.80/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
DBSubnet1CIDR:
Description: Please enter the IP range (CIDR notation) for the DB subnet in the first Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.96/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
DBSubnet2CIDR:
Description: Please enter the IP range (CIDR notation) for the DB subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.112/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
DBSubnet3CIDR:
Description: Please enter the IP range (CIDR notation) for the DB subnet in the second Availability Zone
Type: String
MinLength: 9
MaxLength: 18
Default: "192.0.2.128/28"
AllowedPattern: "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})"
ConstraintDescription: "must be a valid CIDR range of the form x.x.x.x/x."
KeyName:
Description: 'Name of an existing EC2 KeyPair to enable SSH access to the instances'
Type: 'AWS::EC2::KeyPair::KeyName'
ConstraintDescription: 'must be the name of an existing EC2 KeyPair.'
Default: key_name
MysqlClusterType:
Type: String
Default: aurora_serverless
AllowedValues:
- aurora
- aurora_serverless
ConstraintDescription: Selected an mysql cluster type from the list.
MysqlUser:
NoEcho: 'true'
Description: Mysql username
Type: String
MinLength: '1'
MaxLength: '16'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
Default: "wordpressadmin"
MysqlPassword:
NoEcho: 'true'
Description: The database admin account password
Type: String
MinLength: '1'
MaxLength: '41'
AllowedPattern: '[a-zA-Z0-9]+'
ConstraintDescription: must contain only alphanumeric characters.
Default: "strongpassword"
KeyName:
Description: 'Name of an existing EC2 KeyPair to enable SSH access to the instances'
Type: 'AWS::EC2::KeyPair::KeyName'
ConstraintDescription: 'must be the name of an existing EC2 KeyPair.'
Default: key_name
InstanceType:
Description: ECS Node instance type
Type: String
Default: t3.large
InstanceTypesOverride:
Description: ECS Node spot instance type
Type: String
Default: "t3.medium,t3.large,t3.xlarge"
ClusterMinSize:
Description: Minimum ECS Nodes
Type: Number
Default: 1
ClusterDesiredSize:
Description: Minimum ECS Nodes in service
Type: Number
Default: 2
ClusterMaxSize:
Description: Max ECS Nodes
Type: Number
Default: 4
OnDemandBaseCapacity:
Description: Minimum on demand ECS Nodes
Type: Number
Default: 0
OnDemandPercentageAboveBaseCapacity:
Description: On demand percentance over base capacity for ECS Nodes
Type: Number
Default: 2
SpotInstancePools:
Description: Spot instances pools for ECS Nodes
Type: Number
Default: 2
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "Network Configuration"
Parameters:
- VpcCIDR
- PublicSubnet1CIDR
- PublicSubnet2CIDR
- PublicSubnet3CIDR
- PrivateSubnet1CIDR
- PrivateSubnet2CIDR
- PrivateSubnet3CIDR
- DBSubnet1CIDR
- DBSubnet2CIDR
- DBSubnet3CIDR
-
Label:
default: "Database Configuration"
Parameters:
- MysqlClusterType
- MysqlUser
- MysqlPassword
-
Label:
default: "Nodes Configuration"
Parameters:
- KeyName
- InstanceType
- InstanceTypesOverride
- ClusterMinSize
- ClusterDesiredSize
- ClusterMaxSize
- OnDemandBaseCapacity
- OnDemandPercentageAboveBaseCapacity
- SpotInstancePools
Resources:
VPC:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: infrastructure/vpc.yaml
Parameters:
StackName: !Ref AWS::StackName
EnvironmentName: !Ref EnvironmentName
VpcCIDR: !Ref VpcCIDR
PublicSubnet1CIDR: !Ref PublicSubnet1CIDR
PublicSubnet2CIDR: !Ref PublicSubnet2CIDR
PublicSubnet3CIDR: !Ref PublicSubnet3CIDR
PrivateSubnet1CIDR: !Ref PrivateSubnet1CIDR
PrivateSubnet2CIDR: !Ref PrivateSubnet2CIDR
PrivateSubnet3CIDR: !Ref PrivateSubnet3CIDR
DBSubnet1CIDR: !Ref DBSubnet1CIDR
DBSubnet2CIDR: !Ref DBSubnet2CIDR
DBSubnet3CIDR: !Ref DBSubnet3CIDR
NetworkACL:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: infrastructure/network-acl.yaml
Parameters:
StackName: !Ref AWS::StackName
EnvironmentName: !Ref EnvironmentName
VpcCIDR: !Ref VpcCIDR
PublicNetworkAcl: !GetAtt VPC.Outputs.PublicNetworkAcl
PrivateNetworkAcl: !GetAtt VPC.Outputs.PrivateNetworkAcl
DBNetworkAcl: !GetAtt VPC.Outputs.DBNetworkAcl
SecurityGroups:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: infrastructure/security-groups.yaml
Parameters:
StackName: !Ref AWS::StackName
EnvironmentName: !Ref EnvironmentName
VPC: !GetAtt VPC.Outputs.VPC
PrivateSubnet1CIDR: !Ref PrivateSubnet1CIDR
PrivateSubnet2CIDR: !Ref PrivateSubnet2CIDR
PrivateSubnet3CIDR: !Ref PrivateSubnet3CIDR
ALB:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: infrastructure/load-balancers.yaml
Parameters:
StackName: !Ref AWS::StackName
EnvironmentName: !Ref EnvironmentName
#LogsBucket: !Ref LogsBucket
VPC: !GetAtt VPC.Outputs.VPC
PublicSubnets: !GetAtt VPC.Outputs.PublicSubnets
PrivateSubnets: !GetAtt VPC.Outputs.PrivateSubnets
SecurityGroup: !GetAtt SecurityGroups.Outputs.LoadBalancerSecurityGroup
InternalSecurityGroup: !GetAtt SecurityGroups.Outputs.InternalLoadBalancerSecurityGroup
ECS:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: infrastructure/ecs-cluster.yaml
Parameters:
StackName: !Ref AWS::StackName
EnvironmentName: !Ref EnvironmentName
KeyName: !Ref KeyName
InstanceType: !Ref InstanceType
InstanceTypesOverride: !Ref InstanceTypesOverride
ClusterMinSize: !Ref ClusterMinSize
ClusterDesiredSize: !Ref ClusterDesiredSize
ClusterMaxSize: !Ref ClusterMaxSize
OnDemandBaseCapacity: !Ref OnDemandBaseCapacity
OnDemandPercentageAboveBaseCapacity: !Ref OnDemandPercentageAboveBaseCapacity
SpotInstancePools: !Ref SpotInstancePools
VPC: !GetAtt VPC.Outputs.VPC
SecurityGroup: !GetAtt SecurityGroups.Outputs.ECSHostSecurityGroup
Subnets: !GetAtt VPC.Outputs.PrivateSubnets