-
Notifications
You must be signed in to change notification settings - Fork 1
/
routing.template.yaml
259 lines (248 loc) · 7.8 KB
/
routing.template.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
AWSTemplateFormatVersion: 2010-09-09
Description: >-
This template creates an Route53 Hosted zone and adds related record sets.
(qs-1r2g4123h)
Parameters:
VPCID:
Type: 'AWS::EC2::VPC::Id'
VPCCIDR:
Description: CIDR block for the VPC
Type: String
PublicSubnetIDs:
Description: List of public subnet IDs where the Load Balancers is deployed.
Type: CommaDelimitedList
PrivateSubnetIDs:
Description: List of private subnet IDs where the Load Balancer is deployed.
Type: CommaDelimitedList
Fqdn:
Description: The fully qualified domain name where the UiPath Orchestrator should be installed
Type: String
HostedZoneID:
Description: The Route 53 hosted zone Id
Type: "String"
Default: ''
SSLCertificateArn:
Description: Arn of SSL certificate to use for the HTTPS listener
Type: String
UseLevel7LoadBalancer:
Type: String
AllowedValues:
- 'ALB'
- 'NLB'
Description: Use a level 7 load balancer
UseInternalLoadBalancer:
Description: Deploy Internal Load Balancer
Type: String
Default: "false"
AllowedValues:
- 'true'
- 'false'
QSS3BucketName:
Type: String
Description: Name of bucket storing the quickstart files
QSS3BucketRegion:
Type: String
Description: Name of region where the bucket storing the quickstart files is located
QSS3KeyPrefix:
Type: String
Description: Quickstart bucket prefix
Conditions:
UsingDefaultBucket: !Equals
- !Ref QSS3BucketName
- uipath-s3-quickstart
UsingAlb: !Equals
- !Ref UseLevel7LoadBalancer
- "ALB"
UsingNlb: !Not
- !Condition UsingAlb
NotUsingPublicSubnets: !Equals ['', !Join ["", !Ref PublicSubnetIDs]]
UsingInternalLoadBalancer: !Or
- !Equals [!Ref UseInternalLoadBalancer, 'true']
- !Condition NotUsingPublicSubnets
CreatingDnsRecords: !Not [!Equals [!Ref HostedZoneID, '']]
NotCreatingDnsRecords: !Not [!Condition CreatingDnsRecords]
NotCreatingDnsRecords&&UsingNlb: !And [!Condition NotCreatingDnsRecords, !Condition UsingNlb]
NotCreatingDnsRecords&&UsingAlb: !And [!Condition NotCreatingDnsRecords, !Condition UsingAlb]
Resources:
AlbStack:
Type: 'AWS::CloudFormation::Stack'
Condition: UsingAlb
Properties:
TemplateURL: !Sub
- >-
https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/alb.template.yaml
- S3Bucket: !If
- UsingDefaultBucket
- !Sub '${QSS3BucketName}-${AWS::Region}'
- !Ref QSS3BucketName
S3Region: !If
- UsingDefaultBucket
- !Ref 'AWS::Region'
- !Ref QSS3BucketRegion
Parameters:
VPCCIDR: !Ref VPCCIDR
VPCID: !Ref VPCID
SubnetIDs: !If [UsingInternalLoadBalancer, !Join [",", !Ref PrivateSubnetIDs], !Join [",", !Ref PublicSubnetIDs]]
SSLCertificateArn: !Ref SSLCertificateArn
UseInternalLoadBalancer: !If [UsingInternalLoadBalancer, "true", "false"]
NlbStack:
Type: 'AWS::CloudFormation::Stack'
Condition: UsingNlb
Properties:
TemplateURL: !Sub
- >-
https://${S3Bucket}.s3.${S3Region}.${AWS::URLSuffix}/${QSS3KeyPrefix}templates/nlb.template.yaml
- S3Bucket: !If
- UsingDefaultBucket
- !Sub '${QSS3BucketName}-${AWS::Region}'
- !Ref QSS3BucketName
S3Region: !If
- UsingDefaultBucket
- !Ref 'AWS::Region'
- !Ref QSS3BucketRegion
Parameters:
VPCID: !Ref VPCID
SubnetIDs: !If [UsingInternalLoadBalancer, !Join [",", !Ref PrivateSubnetIDs], !Join [",", !Ref PublicSubnetIDs]]
UseInternalLoadBalancer: !If [UsingInternalLoadBalancer, "true", "false"]
KubeLoadBalancer:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
Properties:
Type: network
Scheme: internal
Subnets: !Ref PrivateSubnetIDs
KubeApiTcpTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Port: 6443
Protocol: TCP
VpcId: !Ref VPCID
TargetGroupAttributes:
- Key: preserve_client_ip.enabled
Value: 'false'
- Key: deregistration_delay.connection_termination.enabled
Value: 'true'
TargetType: instance
HealthCheckPort: '6443'
HealthCheckProtocol: TCP
KubeApiTcpListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
LoadBalancerArn: !Ref KubeLoadBalancer
Port: 6443
Protocol: TCP
DefaultActions:
- Type: forward
TargetGroupArn: !Ref KubeApiTcpTargetGroup
Rke2RegistrationTcpTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
Port: 9345
Protocol: TCP
VpcId: !Ref VPCID
TargetGroupAttributes:
- Key: preserve_client_ip.enabled
Value: 'false'
- Key: deregistration_delay.connection_termination.enabled
Value: 'true'
TargetType: instance
HealthCheckPort: '9345'
HealthCheckProtocol: TCP
Rke2RegistrationTcpListener:
Type: 'AWS::ElasticLoadBalancingV2::Listener'
Properties:
LoadBalancerArn: !Ref KubeLoadBalancer
Port: 9345
Protocol: TCP
DefaultActions:
- Type: forward
TargetGroupArn: !Ref Rke2RegistrationTcpTargetGroup
RootRecordSet:
Type: 'AWS::Route53::RecordSet'
Condition: CreatingDnsRecords
Properties:
HostedZoneId: !Ref HostedZoneID
Name: !Join
- ''
- - "*."
- !Ref Fqdn
Type: A
AliasTarget:
EvaluateTargetHealth: false
DNSName: !If
- UsingAlb
- !GetAtt
- AlbStack
- Outputs.ExternalLoadBalancerDns
- !GetAtt
- NlbStack
- Outputs.ExternalLoadBalancerDns
HostedZoneId: !If
- UsingAlb
- !GetAtt
- AlbStack
- Outputs.CanonicalHostedZoneID
- !GetAtt
- NlbStack
- Outputs.CanonicalHostedZoneID
SubdomainRecordSet:
Type: 'AWS::Route53::RecordSet'
Condition: CreatingDnsRecords
Properties:
HostedZoneId: !Ref HostedZoneID
Name: !Ref Fqdn
Type: A
AliasTarget:
EvaluateTargetHealth: false
DNSName: !If
- UsingAlb
- !GetAtt
- AlbStack
- Outputs.ExternalLoadBalancerDns
- !GetAtt
- NlbStack
- Outputs.ExternalLoadBalancerDns
HostedZoneId: !If
- UsingAlb
- !GetAtt
- AlbStack
- Outputs.CanonicalHostedZoneID
- !GetAtt
- NlbStack
- Outputs.CanonicalHostedZoneID
NlbWaitHandle:
DependsOn: NlbStack
Condition: NotCreatingDnsRecords&&UsingNlb
Type: "AWS::CloudFormation::WaitConditionHandle"
AlbWaitHandle:
DependsOn: AlbStack
Condition: NotCreatingDnsRecords&&UsingAlb
Type: "AWS::CloudFormation::WaitConditionHandle"
DnsRecordsWaitCondition:
Type: "AWS::CloudFormation::WaitCondition"
Condition: NotCreatingDnsRecords
Properties:
Handle: !If [UsingNlb, !Ref NlbWaitHandle , !Ref AlbWaitHandle]
Timeout: "43200"
Count: 1
Outputs:
DeploymentTargetGroupArn:
Value: !If
- UsingAlb
- !GetAtt
- AlbStack
- Outputs.TcpTargetGroup
- !GetAtt
- NlbStack
- Outputs.TcpTargetGroup
Description: Deployment target group ARN
KubeTargetGroupArn:
Value: !Ref KubeApiTcpTargetGroup
Description: Kube API target group ARN
Rke2RegistrationTargetGroupArn:
Value: !Ref Rke2RegistrationTcpTargetGroup
Description: Rke2 registration address target group ARN
KubeLoadBalancerArn:
Value: !Ref KubeLoadBalancer
Description: ARN for the internal load balancer balancing the kube API traffic
KubeLoadBalancerDns:
Value: !GetAtt KubeLoadBalancer.DNSName