documentation updates

This commit is contained in:
Alex Schoof
2021-08-29 16:44:38 -04:00
parent 0d84b05447
commit 4fc07f6348
2 changed files with 14 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
# ThunderCloud - Lightning in the Cloud!
This project makes it really easy (or at least as easy as it can be) to run a lightning node *cheaply* in the cloud. It contains a CDK (https://docs.aws.amazon.com/cdk/latest/guide/home.html) stack that sets up the required networking and an EC2 instance to run your node, and a setup script that installs and configures LND using neutrino as the backend. The EC2 instance used is a `t4g.micro`, an ARM-based instance with a gig of memory and two cores which runs just over $6/month, or just below $4/month if you commit to a year through a Reserved Instance (https://aws.amazon.com/ec2/pricing/reserved-instances/). So for ~$6 a month you can run a lightning node and now worry about hardware, power, networking, etc. Or if you want to run it for 2 weeks to try some experiment or something, you can and then just tear it down and stop the meter!
This project makes it really easy (or at least as easy as it can be) to run a lightning node *cheaply* in the cloud. It contains a CDK (https://docs.aws.amazon.com/cdk/latest/guide/home.html) stack that sets up the required networking and an EC2 instance to run your node, and a setup script that installs and configures LND using neutrino as the backend. The EC2 instance used is a `t4g.micro`, an ARM-based instance with a gig of memory and two cores which runs just over $6/month, or just below $4/month if you commit to a year through a Reserved Instance (https://aws.amazon.com/ec2/pricing/reserved-instances/). So for ~$6 a month you can run a lightning node and not worry about hardware, power, networking, etc. Or if you want to run it for 2 weeks to try some experiment or something, you can and then just tear it down and stop the meter!
## Things you need to do first
- Install the AWS CLI (https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) and set it up with AWS creds.
@@ -31,6 +31,7 @@ You can use `lncli` to open channels, create invoices, do all the fun lightning
There is no step 2. You can also go find the stack in CloudFormation and delete it there. either way works.
## Stuff to look at and customize
- You'll want to change the node alias. Either set the right line in `lib/configure-node.sh` before you run `cdk deploy`, or update `~/.lnd/lnd.conf` and restart lnd on the instance. either works.
- Want to see the CFn template that CDK creates? do `cdk synth` from the project root and it'll spit out the yaml template that Cloudformation will use to create the resources.
- When your node first boots, it'll execute `lib/configure-node.sh` as root. This is where lnd gets downloaded and configured. Feel free to tweak it to your needs.
- All the infrastructure is defined in `lib/lightningnode-stack.ts`. You can add/remove/change things there to your liking. doing a `cdk deploy` will update the stack. Changing some instance properties will result in the node being deleted and recreated. Be careful changing the instance.

View File

@@ -1,11 +1,14 @@
#!/bin/bash
# Download and unpack the latest lnd.
wget https://github.com/lightningnetwork/lnd/releases/download/v0.13.1-beta/lnd-linux-arm64-v0.13.1-beta.tar.gz
# TODO: verify signatures on the download
tar xf lnd-linux-arm64-v0.13.1-beta.tar.gz
mkdir /home/ec2-user/bin
cp lnd-linux-arm64-v0.13.1-beta/* /home/ec2-user/bin/
rm -rf lnd-linux-arm64-v0.13.1-beta*
# Write lnd config. Feel free to customize this to your liking. You'll want to change the node alias
mkdir /home/ec2-user/.lnd
PUBLIC_IPV4=$(curl http://169.254.169.254/latest/meta-data/public-ipv4/)
cat << EOF > /home/ec2-user/.lnd/lnd.conf
@@ -140,8 +143,12 @@ routerrpc.penaltyhalflife=6h0m0s
routing.assumechanvalid=1
EOF
# Generate a random password for the lnd wallet.
# Note: YOU should still be the one to run `lnd create` so that you can write down the seed backup
openssl rand -hex 21 > /home/ec2-user/.lnd/wallet_password
# Write a systemd script so it starts up at boot or restarts if it dies
cat << EOF > /etc/systemd/system/lnd.service
[Service]
Environment=HOME=/home/ec2-user
@@ -160,6 +167,7 @@ WantedBy=multi-user.target
EOF
# Setup bos. currently kind of broken. npm gets installed though
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
yum install -y nodejs
mkdir /home/ec2-user/.npm-global
@@ -167,10 +175,13 @@ npm config set prefix '/home/ec2-user/.npm-global'
echo 'PATH=/home/ec2-user/.npm-global/bin:$PATH' >> /home/ec2-user/.bashrc
npm install -g balanceofsatoshis
# make sure the user owns everything we just did
chown -R ec2-user: /home/ec2-user/.lnd
chown -R ec2-user: /home/ec2-user/.npm-global
chown -R ec2-user: /home/ec2-user/bin
# ensure the wallet is unlocked by unlocking it every 5 minutes
echo '*/5 * * * * ec2-user /home/ec2-user/.npm-global/bin/bos unlock /home/ec2-user/.lnd/wallet_password' >> /etc/crontab
# Start lnd!
systemctl start lnd.service