-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfolding.yml
206 lines (193 loc) Β· 5.67 KB
/
folding.yml
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
AWSTemplateFormatVersion: "2010-09-09"
Description: Folding@Home
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
-
Label:
default: "AWS Resources Configuration"
Parameters:
- InstanceType
-
Label:
default: "Folding@Home project"
Parameters:
- FoldingUser
- FoldingPasskey
- FoldingTeam
ParameterLabels:
FoldingUser:
default: "[Optional] Username for your contributions (allowed characters: letters, numbers and underscore '_')"
FoldingPasskey:
default: "[Required if you set Username above] Passkey for your username (get it here - https://apps.foldingathome.org/getpasskey)"
FoldingTeam:
default: "[Optional] Team ID: pick from the list (https://stats.foldingathome.org/teams, e.g. 'Ukraine' team ID is 2164) of create your own team (https://apps.foldingathome.org/team)"
InstanceType:
default: "Instance type to run"
Parameters:
InstanceType:
Type: String
AllowedValues:
- c5.large
- c5.xlarge
- c5.2xlarge
- g4dn.xlarge
- g4dn.2xlarge
FoldingUser:
Type: String
Default: "Anonymous"
AllowedPattern: "[a-zA-Z0-9_]+"
FoldingPasskey:
Type: String
Default: ""
NoEcho: true
FoldingTeam:
Type: Number
Default: 0
Mappings:
ImagesToRegionMap:
ap-northeast-1:
HVM64: ami-09c0c16fc46a29ed9
ap-northeast-2:
HVM64: ami-034ed9c75bff01166
ap-south-1:
HVM64: ami-072992e3a0b57c777
ap-southeast-1:
HVM64: ami-04f2719aea9710d47
ap-southeast-2:
HVM64: ami-0347c3b4134acc4a1
ca-central-1:
HVM64: ami-0644f010d37d638eb
eu-central-1:
HVM64: ami-0c1485978e756d31f
eu-west-1:
HVM64: ami-078c3ac22c6019640
eu-west-2:
HVM64: ami-0b14f7f8838d3469d
eu-west-3:
HVM64: ami-0de4c0ceb16714a07
sa-east-1:
HVM64: ami-01b1c089e7c279034
us-east-1:
HVM64: ami-0b0b075706e19de29
us-east-2:
HVM64: ami-0f3c887052a4defe9
us-west-1:
HVM64: ami-08f684ec10115acdf
us-west-2:
HVM64: ami-03a2978660a16f580
Resources:
IAMRole:
Type: AWS::IAM::Role
Properties:
Description: String
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
Tags:
- Key: Project
Value: Folding@Home
IamInstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref IAMRole
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow http to the worker node
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
Tags:
- Key: Project
Value: Folding@Home
LaunchTemplate:
Type: "AWS::EC2::LaunchTemplate"
Metadata:
AWS::CloudFormation::Init:
configSets:
InstallAndRun:
- "Configure"
- "Install"
Install:
packages:
rpm:
fahclient: "https://download.foldingathome.org/releases/public/release/fahclient/centos-6.7-64bit/v7.6/latest.rpm"
Configure:
commands:
mkdir:
command: "mkdir -p /etc/fahclient"
files:
/etc/fahclient/config.xml:
content: !Sub
<config>
<!-- Preferred disease research -->
<cause v='COVID_19'/>
<!-- HTTP Server -->
<allow v='127.0.0.1'/>
<!-- Slot Control -->
<power v='FULL'/>
<!-- User Information -->
<user v='${FoldingUser}'/>
<passkey v='${FoldingPasskey}'/>
<team v='${FoldingTeam}'/>
<!-- Web Server -->
<web-allow v='127.0.0.1'/>
<!-- Folding Slots -->
<slot id='0' type='CPU'/>
<slot id='1' type='GPU'/>
</config>
mode: "000644"
owner: "root"
group: "root"
Properties:
LaunchTemplateName: FoldingAtHome
LaunchTemplateData:
IamInstanceProfile:
Name: !Ref IamInstanceProfile
ImageId: !FindInMap [ImagesToRegionMap, !Ref "AWS::Region", HVM64]
InstanceType: !Ref InstanceType
InstanceMarketOptions:
MarketType: spot
SecurityGroupIds:
- !GetAtt SecurityGroup.GroupId
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
# Install the files and packages from the metadata
/opt/aws/bin/cfn-init -v \
--stack ${AWS::StackName} \
--resource LaunchTemplate --configsets InstallAndRun \
--region ${AWS::Region}
AutoScalingGroup:
UpdatePolicy:
AutoScalingReplacingUpdate:
WillReplace: true
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
AvailabilityZones: !GetAZs
DesiredCapacity: 1
LaunchTemplate:
LaunchTemplateId:
Ref: LaunchTemplate
Version: !GetAtt LaunchTemplate.LatestVersionNumber
MaxSize: 1
MinSize: 0
Tags:
- Key: Project
Value: Folding@Home
PropagateAtLaunch: true
- Key: Name
Value: FoldingAtHome
PropagateAtLaunch: true