-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathdeadline-cloud-smf-vpc-fsx-template.yaml
More file actions
363 lines (335 loc) · 10.7 KB
/
Copy pathdeadline-cloud-smf-vpc-fsx-template.yaml
File metadata and controls
363 lines (335 loc) · 10.7 KB
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
AWSTemplateFormatVersion: 2010-09-09
Description: >
AWS Deadline Cloud service-managed fleet with FSx for OpenZFS storage accessed via VPC resource endpoint.
This template demonstrates how to connect Deadline Cloud workers to private VPC resources using VPC Lattice.
See the README.md included with the CloudFormation template to learn more.
Parameters:
FarmName:
Type: String
Default: SMF VPC FSx Farm
Description: Display name for the Deadline Cloud farm.
FleetName:
Type: String
Default: SMF VPC Fleet
Description: Display name for the Deadline Cloud fleet.
QueueName:
Type: String
Default: FSx Job Queue
Description: Display name for the Deadline Cloud queue.
FSxClusterIP:
Type: String
Default: 10.0.1.100
Description: >
IP address of the FSx cluster. After initial deployment, update this parameter with the
actual IP address from the FSx network interface. See the README for instructions.
MaxWorkerCount:
Type: Number
Default: 5
Description: Maximum number of worker hosts in the fleet.
MinVcpu:
Type: Number
Default: 1
Description: Minimum number of vCPUs for fleet instances.
MaxVcpu:
Type: Number
Default: 4
Description: Maximum number of vCPUs for fleet instances.
MinMemoryMiB:
Type: Number
Default: 512
Description: Minimum MiB RAM for fleet instances.
MaxMemoryMiB:
Type: Number
Default: 8192
Description: Maximum MiB RAM for fleet instances.
InstanceMarketType:
Type: String
Default: on-demand
Description: Whether to use on-demand or spot instances.
AllowedValues:
- on-demand
- spot
Resources:
# VPC Infrastructure
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsHostnames: true
EnableDnsSupport: true
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-vpc
Subnet1:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.0.1.0/24
AvailabilityZone: !Select [0, !GetAZs ""]
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-subnet-1
Subnet2:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref VPC
CidrBlock: 10.0.2.0/24
AvailabilityZone: !Select [1, !GetAZs ""]
MapPublicIpOnLaunch: true
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-subnet-2
InternetGateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-igw
VPCGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref VPC
InternetGatewayId: !Ref InternetGateway
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
Tags:
- Key: Name
Value: !Sub ${AWS::StackName}-rt
Route:
Type: AWS::EC2::Route
DependsOn: VPCGatewayAttachment
Properties:
RouteTableId: !Ref RouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
SubnetRouteTableAssociation1:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref Subnet1
RouteTableId: !Ref RouteTable
SubnetRouteTableAssociation2:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref Subnet2
RouteTableId: !Ref RouteTable
# Security Group for FSx and VPC Lattice
FSxSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for FSx OpenZFS and VPC Lattice resource gateway
VpcId: !Ref VPC
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: 0.0.0.0/0
Description: Allow all outbound traffic
FSxSecurityGroupSelfIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: !Ref FSxSecurityGroup
IpProtocol: -1
SourceSecurityGroupId: !Ref FSxSecurityGroup
Description: Allow all traffic from same security group
# FSx for OpenZFS File System
FSxFileSystem:
Type: AWS::FSx::FileSystem
Properties:
FileSystemType: OPENZFS
StorageCapacity: 64
SubnetIds:
- !Ref Subnet1
SecurityGroupIds:
- !Ref FSxSecurityGroup
OpenZFSConfiguration:
DeploymentType: SINGLE_AZ_1
ThroughputCapacity: 64
RootVolumeConfiguration:
NfsExports:
- ClientConfigurations:
- Clients: "*"
Options:
- rw
- crossmnt
# 'insecure' allows NFS connections from non-privileged ports (>1024), required for NAT
- insecure
# VPC Lattice Resources
VPCLatticeResourceGateway:
Type: AWS::VpcLattice::ResourceGateway
Properties:
Name: !Sub ${AWS::StackName}-resource-gateway
IpAddressType: IPV4
VpcIdentifier: !Ref VPC
SubnetIds:
- !Ref Subnet1
- !Ref Subnet2
SecurityGroupIds:
- !Ref FSxSecurityGroup
VPCLatticeResourceConfiguration:
Type: AWS::VpcLattice::ResourceConfiguration
Properties:
Name: !Sub ${AWS::StackName}-resource-config
AllowAssociationToSharableServiceNetwork: true
ResourceConfigurationType: SINGLE
ProtocolType: TCP
PortRanges:
- 1-65535
ResourceGatewayId: !GetAtt VPCLatticeResourceGateway.Id
ResourceConfigurationDefinition:
IpResource: !Ref FSxClusterIP
# Deadline Cloud Resources
DeadlineFarm:
Type: AWS::Deadline::Farm
Properties:
DisplayName: !Ref FarmName
FleetRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: credentials.deadline.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount: !Ref AWS::AccountId
ArnEquals:
aws:SourceArn: !Ref DeadlineFarm
ManagedPolicyArns:
- !Sub arn:${AWS::Partition}:iam::aws:policy/AWSDeadlineCloud-FleetWorker
Policies:
- PolicyName: FleetWorkerLogs
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- logs:CreateLogStream
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:*:/aws/deadline/${DeadlineFarm.FarmId}/*
Condition:
ForAnyValue:StringEquals:
aws:CalledVia:
- deadline.amazonaws.com
- Effect: Allow
Action:
- logs:PutLogEvents
- logs:GetLogEvents
Resource: !Sub arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:*:/aws/deadline/${DeadlineFarm.FarmId}/*
QueueRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: credentials.deadline.amazonaws.com
Action: sts:AssumeRole
Condition:
StringEquals:
aws:SourceAccount: !Ref AWS::AccountId
ArnEquals:
aws:SourceArn: !Ref DeadlineFarm
Policies:
- PolicyName: QueuePolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: JobLogsReadOnly
Effect: Allow
Action:
- logs:GetLogEvents
Resource: !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/deadline/${DeadlineFarm.FarmId}/*
- Sid: DeadlineServiceManagedFleetSoftwareAccess
Effect: Allow
Action:
- s3:ListBucket
- s3:GetObject
Resource: "*"
Condition:
ArnLike:
s3:DataAccessPointArn:
- arn:aws:s3:*:*:accesspoint/deadline-software-*
StringEquals:
s3:AccessPointNetworkOrigin: VPC
DeadlineFleet:
Type: AWS::Deadline::Fleet
Properties:
DisplayName: !Ref FleetName
FarmId: !GetAtt DeadlineFarm.FarmId
RoleArn: !GetAtt FleetRole.Arn
MaxWorkerCount: !Ref MaxWorkerCount
MinWorkerCount: 0
Configuration:
ServiceManagedEc2:
InstanceCapabilities:
VCpuCount:
Min: !Ref MinVcpu
Max: !Ref MaxVcpu
MemoryMiB:
Min: !Ref MinMemoryMiB
Max: !Ref MaxMemoryMiB
OsFamily: LINUX
CpuArchitectureType: x86_64
InstanceMarketOptions:
Type: !Ref InstanceMarketType
VpcConfiguration:
ResourceConfigurationArns:
- !GetAtt VPCLatticeResourceConfiguration.Arn
HostConfiguration:
ScriptBody: !Sub
- |
#!/bin/bash
set -e
sudo mkdir -p /mnt/fsx
NFS_DNS="${ResourceConfigId}.resource-endpoints.deadline.${AWS::Region}.amazonaws.com"
sudo mount -t nfs -o nfsvers=4.1 $NFS_DNS:/fsx /mnt/fsx
echo "NFS mount successful at /mnt/fsx"
- ResourceConfigId: !GetAtt VPCLatticeResourceConfiguration.Id
ScriptTimeoutSeconds: 300
DeadlineQueue:
Type: AWS::Deadline::Queue
Properties:
DisplayName: !Ref QueueName
FarmId: !GetAtt DeadlineFarm.FarmId
DefaultBudgetAction: NONE
RoleArn: !GetAtt QueueRole.Arn
QueueFleetAssociation:
Type: AWS::Deadline::QueueFleetAssociation
Properties:
FarmId: !GetAtt DeadlineFarm.FarmId
QueueId: !GetAtt DeadlineQueue.QueueId
FleetId: !GetAtt DeadlineFleet.FleetId
# RAM Resource Share to allow Deadline service access to VPC Lattice resource
ResourceShare:
Type: AWS::RAM::ResourceShare
Properties:
Name: !Sub ${AWS::StackName}-VPCLattice-Share
ResourceArns:
- !GetAtt VPCLatticeResourceConfiguration.Arn
Principals:
- fleets.deadline.amazonaws.com
Sources:
- !Ref AWS::AccountId
Outputs:
FarmId:
Description: Deadline Farm ID
Value: !Ref DeadlineFarm
FleetId:
Description: Deadline Fleet ID
Value: !Ref DeadlineFleet
QueueId:
Description: Deadline Queue ID
Value: !Ref DeadlineQueue
FSxFileSystemId:
Description: FSx File System ID
Value: !Ref FSxFileSystem
FSxDNSName:
Description: FSx DNS Name for direct NFS mount
Value: !GetAtt FSxFileSystem.DNSName
VPCLatticeEndpoint:
Description: VPC Lattice endpoint for NFS access via Deadline workers
Value: !Sub ${VPCLatticeResourceConfiguration.Id}.resource-endpoints.deadline.${AWS::Region}.amazonaws.com