This post was written in 2018. Tools and versions mentioned may be outdated, though the underlying ideas still hold.
Demo code for deploying cryptocurrency nodes across multiple AWS regions with Terraform is here.
The directory structure looks like this:
The idea is simple: put each coin’s deployment scripts in its own folder, then call each module from main.tf. This isn’t for mining — it’s purely for syncing wallet nodes. Deploying across multiple regions keeps the nodes as up-to-date as possible with the latest blocks. You can also spin up multiple instances per region if needed.
module "coinnode-us-east-1" { |
Let’s walk through a single example — using KRB (Karbo) as the case study:
- module.tf
// Search for the AMI |
- vpc.tf
|
Note
- When deploying across multiple regions, the same AMI can have different image IDs in different regions — so don’t hardcode the AMI ID. Use filter-based lookups instead.
- For security groups, only open what you actually need: the RPC port, the P2P port, and maybe a custom service port restricted to specific IPs. Don’t leave unnecessary ports open.
- If you have GuardDuty enabled, all the traffic from node syncing will get flagged as suspicious. With SNS configured on top, you’ll get notified on every single sync… heads up.
- When running non-background processes with Terraform provisioners, add a
sleepafter launching them. Otherwise Terraform exits the build before the remote server has a chance to finish executing the script. - Every
.tffile in the current directory gets executed. Using different filenames to separate concerns is just a code organization convention — Terraform doesn’t care about the names.