-
Notifications
You must be signed in to change notification settings - Fork 2
/
ethereum-cf-stack.yml
197 lines (192 loc) · 6.43 KB
/
ethereum-cf-stack.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
# AWS Ethereum CloudFormation Stack
# Kenneth Falck <[email protected]> 2016
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
TeamId:
Description: "Team ID"
Default: "master"
Type: "String"
NetworkId:
Description: "Network ID"
Default: "42424242"
Type: "String"
KeyName:
Description: "Key pair name"
Default: "ethereum"
Type: "String"
InstanceType:
Description: "Instance type"
Default: "t2.micro"
Type: "String"
ImageId:
Description: "Image AMI ID (default Ubuntu 16.04)"
Default: "ami-07174474"
Type: "String"
VolumeSize:
Description: "Instance volume size in GB"
Default: "20"
Type: "String"
AvailabilityZone:
Description: "Availability zone"
Default: "eu-west-1a"
Type: "String"
Domain:
Description: "Domain name for DNS names"
Default: "blockchain-bootcamp.com"
Type: "String"
MasterAccountId:
Description: "Master Account ID"
Default: "e986f163e65361be0f08aa48dcc3a7b12a57baf0"
Type: "String"
DeployPassword:
Description: "Deploy Password"
Default: ""
Type: "String"
Conditions:
IsMaster:
"Fn::Equals":
- !Ref TeamId
- master
IsNotMaster:
"Fn::Not":
- "Fn::Equals":
- !Ref TeamId
- master
Resources:
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: "Ethereum security group"
SecurityGroupIngress:
- CidrIp: "0.0.0.0/0"
IpProtocol: tcp
FromPort: 22
ToPort: 22
- CidrIp: "0.0.0.0/0"
IpProtocol: tcp
FromPort: 80
ToPort: 80
- CidrIp: "0.0.0.0/0"
IpProtocol: tcp
FromPort: 443
ToPort: 443
- CidrIp: "0.0.0.0/0"
IpProtocol: tcp
FromPort: 30300
ToPort: 30399
- CidrIp: "0.0.0.0/0"
IpProtocol: udp
FromPort: 30300
ToPort: 30399
SecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupName: !Ref SecurityGroup
SourceSecurityGroupName: !Ref SecurityGroup
IpProtocol: -1
FromPort: -1
ToPort: -1
Volume1:
Type: AWS::EC2::Volume
Properties:
Size: !Ref VolumeSize
VolumeType: "gp2"
AvailabilityZone: !Ref AvailabilityZone
Node1:
Type: AWS::EC2::Instance
Properties:
InstanceType: !Ref InstanceType
ImageId: !Ref ImageId
KeyName: !Ref KeyName
AvailabilityZone: !Ref AvailabilityZone
SecurityGroups:
- !Ref SecurityGroup
UserData:
"Fn::Base64":
"Fn::Join":
- "\n"
-
- "#!/bin/bash -xe"
- "export DEBIAN_FRONTEND=noninteractive"
- !Sub "export NETWORK_ID=${NetworkId}"
- !Sub "export TEAM_ID=${TeamId}"
- !Sub "export MASTER_ACCOUNT_ID=${MasterAccountId}"
- !Sub "export DOMAIN=${Domain}"
- "apt-get install --yes --force-yes -q software-properties-common"
- "add-apt-repository -y ppa:ethereum/ethereum"
- "apt-get update -q"
- "apt-get upgrade --yes --force-yes"
- "apt-get install --yes --force-yes -q ethereum solc apache2"
- "adduser --home /home/ethereum --disabled-password --gecos Ethereum ethereum"
- "mkdir /home/ethereum/.ssh"
- "curl -s -o /home/ethereum/.ssh/id_rsa.pub https://blockchain-bootcamp.com/files/cloud/ll-ethereum-guest.pub"
- "curl -s -o /home/ethereum/ll-ethereum-guest.pem.gpg https://blockchain-bootcamp.com/files/cloud/ll-ethereum-guest.pem.gpg"
- "gpg --passphrase ${DeployPassword} -d -o /home/ethereum/.ssh/id_rsa /home/ethereum/.ssh/ll-ethereum-guest.pem.gpg"
- "curl -s -o /home/ethereum/genesis.json https://blockchain-bootcamp.com/files/cloud/genesis.json"
- "curl -s -o /home/ethereum/ethereum.sh https://blockchain-bootcamp.com/files/cloud/ethereum.sh"
- "curl -s -o /usr/lib/cgi-bin/ethereum.py https://blockchain-bootcamp.com/files/cloud/ethereum.py"
- "curl -s -o /var/www/html/index.html https://blockchain-bootcamp.com/files/cloud/index.html"
- "chown -R ethereum:ethereum /home/ethereum/.ssh"
- "chmod 600 /home/ethereum/.ssh/id_rsa"
- "chmod 755 /home/ethereum/ethereum.sh /usr/lib/cgi-bin/ethereum.py"
- "touch /var/www/html/nodeinfo.json /var/www/html/ip.json"
- "cp /home/ethereum/genesis.json /var/www/html/genesis.json"
- "chown ethereum:ethereum /home/ethereum/* /home/ethereum/.ssh /var/www/html /var/www/html/* /usr/lib/cgi-bin/*"
- "a2enmod cgid"
- "echo 'export APACHE_RUN_USER=ethereum' >> /etc/apache2/envvars"
- "service apache2 restart"
- "echo NETWORK_ID=$NETWORK_ID >> /etc/environment"
- "echo TEAM_ID=$TEAM_ID >> /etc/environment"
- "echo MASTER_ACCOUNT_ID=$MASTER_ACCOUNT_ID >> /etc/environment"
- "echo DOMAIN=$DOMAIN >> /etc/environment"
- "echo 'PATH=$PATH:/opt/jdk/bin' > /etc/profile.d/jdk-path.sh"
- "echo '#!/bin/sh' > /etc/rc.local"
- "echo 'sudo -u ethereum -E /home/ethereum/ethereum.sh &' >> /etc/rc.local"
- "echo 'exit 0' >> /etc/rc.local"
- "exec sudo -u ethereum -E /home/ethereum/ethereum.sh"
Volumes:
- Device: "xvdh"
VolumeId: !Ref Volume1
Tags:
- Key: Name
Value: !Sub "Ethereum-${TeamId}-1"
Node1RecordSet:
Type: "AWS::Route53::RecordSet"
Condition:
IsNotMaster
Properties:
Name:
"Fn::Join":
- ""
-
- !Ref TeamId
- "."
- !Ref Domain
- "."
HostedZoneName:
"Fn::Join":
- ""
-
- !Ref Domain
- "."
Type: "CNAME"
TTL: "300"
ResourceRecords:
- !GetAtt Node1.PublicDnsName
MasterIPAddress:
Type: "AWS::EC2::EIPAssociation"
Condition: IsMaster
Properties:
InstanceId: !Ref Node1
AllocationId: eipalloc-ee112d8a
Outputs:
Node1InstanceId:
Description: "Node1 Instance Id"
Value: !Ref Node1
Node1PublicIp:
Description: "Node1 Public Ip"
Value: !GetAtt Node1.PublicIp
Node1PublicDnsName:
Condition: IsNotMaster
Description: "Node1 Public DNS Name"
Value: !Ref Node1RecordSet