Environment variables:
TF_VAR_AWS_ACCESS_KEY
TF_VAR_AWS_SECRET_KEY
TF_VAR_SSH_PASSWORD
TF_VAR_REGION
Dependencies:
- aws-cli
- terraform
- ansible
- jq (for parsing json)
- ssh keys (
~/.ssh/id_rsa
and~/.ssh/id_rsa.pub
)
- Get an ip address alocated and append to ansible hosts, export the address to environment
git clone https://github.com/piotrostr/eth-mainnet-light-node
aws ec2 allocate-address > /etc/allocated-address
export NODE_IP=$(cat /etc/allocated-address | jq -r ".PublicIp")
export TF_VAR_ALLOCATION_ID=$(cat /etc/allocated-address | jq -r ".AllocationId")
echo $NODE_IP >> /etc/ansible/hosts
in case one would prefer to maintain the same address, the setting of the NODE_IP
and TF_VAR_ALLOCATION_ID
variables can be appended to ~/.profile or ~/.bashrc
- Start and setup the instance
cd ./terraform && terraform init && terraform apply
cd ../
ansible-playbook ansible/main.yml
ssh ubuntu@$NODE_IP
- Choose a node and run, either a light node
geth --syncmode light --http
or a full node
geth --http
- After the geth node synchronizes with the mainnet it can accept requests
curl http://$NODE_IP:8545/
Destroy the resources
cd ./terraform
terraform destroy
Cleanup after the ip address
aws ec2 release-address --allocation-id $TF_VAR_ALLOCATION_ID
rm /etc/allocated-address
and dont forget to remove the host $(echo $NODE_IP)
from /etc/ansible/hosts