This repository has been archived by the owner on Oct 11, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 69
/
turbine-master.template
287 lines (279 loc) · 10.6 KB
/
turbine-master.template
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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
This template creates a Quick Start VPC stack and a Turbine Airflow cluster
stack. The Quick Start VPC stack creates a Multi-AZ VPC infrastructure with
two private subnets and managed NAT gateways in the two public subnets. The
Turbine Airflow cluster stack creates the Airflow supporting resources
including an RDS instance to host the Airflow metadata database, an SQS queue
to be used as broker backend, S3 buckets for logs and deployment packages, and
then creates the Airflow scheduler, webserver and workers nested stacks. The
nested Airflow services stacks create the Airflow instances in highly
available auto scaling groups spanning two subnets, plus for the workers stack
an EFS shared network directory and a custom cloudwatch load metric function
to guide the auto scaling alarm triggers. **WARNING** This template creates
AWS resources. You will be billed for the AWS resources used if you create a
stack from this template. QS(0027)
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: VPC network configuration
Parameters:
- VPCCIDR
- PublicSubnet1CIDR
- PublicSubnet2CIDR
- PrivateSubnet1ACIDR
- PrivateSubnet2ACIDR
- AllowHTTPAccessCIDR
- Label:
default: Turbine Cluster configuration
Parameters:
- SchedulerInstanceType
- WebserverInstanceType
- WorkerInstanceType
- MinGroupSize
- MaxGroupSize
- ShrinkThreshold
- GrowthThreshold
- Label:
default: Apache Airflow configuration
Parameters:
- LoadExampleDags
- LoadDefaultCons
- WebServerPort
- Label:
default: AWS Quick Start configuration
Parameters:
- QSS3BucketName
- QSS3KeyPrefix
ParameterLabels:
VPCCIDR:
default: VPC CIDR
PublicSubnet1CIDR:
default: Public subnet 1 CIDR
PublicSubnet2CIDR:
default: Public subnet 2 CIDR
PrivateSubnet1ACIDR:
default: Private subnet 1 CIDR
PrivateSubnet2ACIDR:
default: Private subnet 2 CIDR
AllowHTTPAccessCIDR:
default: Allowed HTTP access CIDR
SchedulerInstanceType:
default: Scheduler instance type
WebserverInstanceType:
default: Web server instance type
WorkerInstanceType:
default: Workers instance type
MinGroupSize:
default: Minimum group size
MaxGroupSize:
default: Maximum group size
ShrinkThreshold:
default: Shrink threshold
GrowthThreshold:
default: Growth threshold
LoadExampleDags:
default: Load example DAGs
LoadDefaultCons:
default: Load default connections
WebServerPort:
default: Web server port
QSS3BucketName:
default: Quick Start S3 bucket name
QSS3KeyPrefix:
default: Quick Start S3 key prefix
Parameters:
VPCCIDR:
Description: >-
CIDR block for the VPC.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.0.0/16
Type: String
PublicSubnet1CIDR:
Description: >-
CIDR block for the public subnet 1 located in Availability Zone 1.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.0.0/24
Type: String
PublicSubnet2CIDR:
Description: >-
CIDR block for the public subnet 1 located in Availability Zone 1.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.1.0/24
Type: String
PrivateSubnet1ACIDR:
Description: >-
CIDR block for private subnet 1 located in Availability Zone 1.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.10.0/24
Type: String
PrivateSubnet2ACIDR:
Description: >-
CIDR block for private subnet 2 located in Availability Zone 2.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.11.0/24
Type: String
AllowHTTPAccessCIDR:
Description: >-
The IPv4 CIDR block to allow HTTP access in the webserver. Using the same
CIDR for the VPC is a secure default. Using 0.0.0.0/0 allows access from
everywhere, which is convenient but less secure.
ConstraintDescription: CIDR block parameter must be in the form x.x.x.x/16-28.
AllowedPattern: ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$
Default: 10.0.0.0/16
Type: String
SchedulerInstanceType:
Description: >-
EC2 instance type to use for the scheduler.
Default: t3.micro
Type: String
WebserverInstanceType:
Description: >-
EC2 instance type to use for the webserver.
Default: t3.micro
Type: String
WorkerInstanceType:
Description: >-
EC2 instance type to use for the workers.
Default: t3.medium
Type: String
MinGroupSize:
Description: >-
The minimum number of active worker instances.
Default: 0
Type: Number
MaxGroupSize:
Description: >-
The maximum number of active worker instances.
Default: 10
Type: Number
ShrinkThreshold:
Description: >-
The threshold for the average queue size from which going equal or below
will trigger the AutoScaling group to Scale In, deallocating one worker
instance.
Default: 0.5
Type: Number
GrowthThreshold:
Description: >-
The threshold for the average queue size from which going equal or above
will trigger the AutoScaling group to Scale Out, allocating one worker
instance.
Default: 0.9
Type: Number
LoadExampleDags:
Description: >-
Load the example DAGs distributed with Airflow. Useful if deploying a
stack for demonstrating a few topologies, operators and scheduling
strategies.
AllowedValues:
- 'False'
- 'True'
Default: 'False'
Type: String
LoadDefaultCons:
Description: >-
Load the default connections initialized by Airflow. Most consider these
unnecessary, which is why the default is to not load them.
AllowedValues:
- 'False'
- 'True'
Default: 'False'
Type: String
WebServerPort:
Description: >-
The port Airflow webserver will be listening.
ConstraintDescription: >-
Ports below 1024 can be opened only with root privileges and the airflow
process does not run as such.
MinValue: 1024
MaxValue: 65535
Default: 8080
Type: Number
QSS3BucketName:
Description: >-
S3 bucket name for the Quick Start assets. You can specify your own bucket
providing assets and submodules, if you want to override the Quick Start
behavior for your specific implementation.
ConstraintDescription: >-
Quick Start bucket name can include numbers, lowercase letters, uppercase
letters, and hyphens (-). It cannot start or end with a hyphen (-).
AllowedPattern: '^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$'
Default: turbine-quickstart
Type: String
QSS3KeyPrefix:
Description: >-
S3 key prefix for the Quick Start assets. You can scpeficy your own
"directory" providing the stack templates, if you want to override the
Quick Start behavior for your specific implementation.
ConstraintDescription: >-
Quick Start key prefix can include numbers, lowercase letters, uppercase
letters, hyphens (-), and forward slash (/).
AllowedPattern: '^[0-9a-zA-Z-/]*$'
Default: quickstart-turbine-airflow/
Type: String
Resources:
VPCStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Join
- ''
- - !Sub https://${QSS3BucketName}.s3.amazonaws.com/
- !Ref QSS3KeyPrefix
- submodules/quickstart-aws-vpc/templates/aws-vpc.template
Parameters:
VPCCIDR: !Ref VPCCIDR
PublicSubnet1CIDR: !Ref PublicSubnet1CIDR
PublicSubnet2CIDR: !Ref PublicSubnet2CIDR
CreatePrivateSubnets: 'true'
PrivateSubnet1ACIDR: !Ref PrivateSubnet1ACIDR
PrivateSubnet2ACIDR: !Ref PrivateSubnet2ACIDR
NumberOfAZs: '2'
AvailabilityZones: !Join
- ','
- - Fn::Select:
- 0
- !GetAZs
- Fn::Select:
- 1
- !GetAZs
TurbineCluster:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Join
- ''
- - !Sub https://${QSS3BucketName}.s3.amazonaws.com/
- !Ref QSS3KeyPrefix
- templates/turbine-cluster.template
Parameters:
VPCID: !GetAtt VPCStack.Outputs.VPCID
PublicSubnet1ID: !GetAtt VPCStack.Outputs.PublicSubnet1ID
PublicSubnet2ID: !GetAtt VPCStack.Outputs.PublicSubnet2ID
PrivateSubnet1AID: !GetAtt VPCStack.Outputs.PrivateSubnet1AID
PrivateSubnet2AID: !GetAtt VPCStack.Outputs.PrivateSubnet2AID
AllowHTTPAccessCIDR: !Ref AllowHTTPAccessCIDR
WebServerPort: !Ref WebServerPort
SchedulerInstanceType: !Ref SchedulerInstanceType
WebserverInstanceType: !Ref WebserverInstanceType
WorkerInstanceType: !Ref WorkerInstanceType
MinGroupSize: !Ref MinGroupSize
MaxGroupSize: !Ref MaxGroupSize
GrowthThreshold: !Ref GrowthThreshold
ShrinkThreshold: !Ref ShrinkThreshold
LoadExampleDags: !Ref LoadExampleDags
LoadDefaultCons: !Ref LoadDefaultCons
QSS3BucketName: !Ref QSS3BucketName
QSS3KeyPrefix: !Ref QSS3KeyPrefix
Outputs:
DeploymentsBucket:
Value: !GetAtt TurbineCluster.Outputs.DeploymentsBucket
CodeDeployApplication:
Value: !GetAtt TurbineCluster.Outputs.CodeDeployApplication
CodeDeployDeploymentGroup:
Value: !GetAtt TurbineCluster.Outputs.CodeDeployDeploymentGroup