forked from mludvig/aws-ethereum-miner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yml
215 lines (196 loc) · 5.87 KB
/
template.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
206
207
208
209
210
211
212
213
214
215
AWSTemplateFormatVersion: '2010-09-09'
Metadata:
RepoUrl: https://github.com/A1iAshoor/aws-ethereum-miner
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Miner Configuration
Parameters:
- EthWallet
- Label:
default: Instance Configuration
Parameters:
- InstanceType
- InstanceAmi
- Label:
default: Networking Configuration
Parameters:
- VpcId
- SubnetIds
Parameters:
InstanceType:
Type: String
AllowedValues:
## The commented-out are not worth it - too slow for the price
#- g3s.xlarge # 1 GPU Tesla M60
#- g3.8xlarge # 2 GPU Tesla M60
- g4dn.xlarge # 1 GPU Tesla T4 -- best value (cost/performance)
- g4dn.2xlarge # 1 GPU Tesla T4
- g4dn.12xlarge # 4 GPU Tesla T4
#- p2.xlarge # 1 GPU Tesla K80
#- p2.8xlarge # 8 GPU Tesla K80
#- p2.16xlarge # 16 GPU Tesla K80
- p3.2xlarge # 1 GPU Tesla V100
- p3.8xlarge # 4 GPU Tesla V100
- p3.16xlarge # 8 GPU Tesla V100
Default: g4dn.xlarge
InstanceCount:
Type: Number
Default: 10
MaxValue: 15
EthWallet:
Type: String
Description: Ethereum Wallet Address
Default: "0x599ba8cdc6eb7b5bab3cc5e90ceb6cb2b2d9fade"
AllowedPattern: "0x[0-9a-fA-F]+"
VpcId:
Description: The VPC where this stack will be deployed
Type: AWS::EC2::VPC::Id
SubnetIds:
Description: The subnets where the instances will be deployed - at least 3 subnets!
Type: List<AWS::EC2::Subnet::Id>
Mappings:
# ImageId of 'Deep Learning AMI (Ubuntu 18.04) Version 36.0' in each region
RegionMap:
ap-northeast-1:
ImageId: ami-03b8cfea5460e4881
ap-northeast-2:
ImageId: ami-07e004f63a0cccdd3
ap-south-1:
ImageId: ami-02cb047909c100c3d
ap-southeast-1:
ImageId: ami-068f673b54015684e
ap-southeast-2:
ImageId: ami-0f558ede443627831
ca-central-1:
ImageId: ami-0ca5bba27cf7db8f0
eu-central-1:
ImageId: ami-01227276a4e5a4a31
eu-north-1:
ImageId: ami-080691999cd85e762
eu-west-1:
ImageId: ami-006ff58f5247c50eb
eu-west-2:
ImageId: ami-096a6497745975f89
eu-west-3:
ImageId: ami-0346672391424d8e5
sa-east-1:
ImageId: ami-048837a0bfc1ba1a6
us-east-1:
ImageId: ami-063585f0e06d22308
us-east-2:
ImageId: ami-01bd6a1621a6968d7
us-west-1:
ImageId: ami-05fbe06ba1b862ef6
us-west-2:
ImageId: ami-0bc87a16c757a7f07
SpotPriceMap:
g4dn.xlarge:
MaxPrice: 0.16
g4dn.2xlarge:
MaxPrice: 0.23
g4dn.12xlarge:
MaxPrice: 1.57
p3.2xlarge:
MaxPrice: 0.92
p3.8xlarge:
MaxPrice: 3.68
p3.16xlarge:
MaxPrice: 7.36
Resources:
InstanceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore'
InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Roles:
- !Ref InstanceRole
LaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateData:
IamInstanceProfile:
Arn: !GetAtt InstanceProfile.Arn
InstanceMarketOptions:
MarketType: spot
SpotOptions:
SpotInstanceType: one-time
MaxPrice: !FindInMap [ SpotPriceMap, !Ref InstanceType, MaxPrice ]
InstanceType: !Ref InstanceType
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", ImageId ]
SecurityGroupIds:
- !Ref SecurityGroup
UserData:
'Fn::Base64':
'Fn::Sub': |
#!/bin/bash -x
cd /tmp
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
wget -O trex.tar.gz https://github.com/trexminer/T-Rex/releases/download/0.20.3/t-rex-0.20.3-linux.tar.gz
tar xvfz trex.tar.gz
cd bin
cat > runner.sh << __EOF__
#!/bin/bash -x
./t-rex -a ethash -o stratum+tcp://eth.2miners.com:2020 -u ${EthWallet} -p x -w ${!INSTANCE_ID} --api-bind-telnet 0 --api-bind-http 0 \
>> /tmp/trex.log 2>&1
__EOF__
chmod +x runner.sh
nohup ./runner.sh &
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: !Ref AWS::StackName
VpcId: !Ref VpcId
SecurityGroupEgress:
- IpProtocol: -1
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Ref AWS::StackName
MinerAsg:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
LaunchTemplate:
LaunchTemplateId: !Ref LaunchTemplate
Version: !GetAtt LaunchTemplate.LatestVersionNumber
MinSize: 0
MaxSize: !Ref InstanceCount
DesiredCapacity: !Ref InstanceCount
CapacityRebalance: false
VPCZoneIdentifier: !Ref SubnetIds
HealthCheckGracePeriod: 300
HealthCheckType: EC2
TerminationPolicies:
- ClosestToNextInstanceHour
NotificationConfigurations:
- TopicARN: !Ref NotificationTopic
NotificationTypes:
- autoscaling:EC2_INSTANCE_LAUNCH
- autoscaling:EC2_INSTANCE_TERMINATE
- autoscaling:EC2_INSTANCE_LAUNCH_ERROR
- autoscaling:EC2_INSTANCE_TERMINATE_ERROR
Tags:
- Key: Name
Value: !Ref AWS::StackName
PropagateAtLaunch: true
NotificationTopic:
Type: AWS::SNS::Topic
Outputs:
NotificationTopic:
Description: Monitoring notification topic
Value: !Ref NotificationTopic
DashboardUrl:
Description: Ethermine Dashboard URL
Value: !Sub "https://eth.2miners.com/account/${EthWallet}"