Hey all, it’s been a while since I posted but I’m back! I’ll be posting a lot more Google Cloud stuff as I’m learning it.
The Terraform scripts for this are on my Github. This will provision a compute engine, set up a couple of firewall rules, and configure the bitcoin core daemon. Then we will log into the instance and check on everything. It’ll take a bit to sync to the blockchain the first time (6–8 hours) and you’ll need at least 250 GB of storage.
New Project Time
First, I created a new project after logging in.
This will create some default resources and firewall rules. I switched over to VPC Network > Firewall Rules to removed all the rules. Terraform will add the necessary rules for the Bitcoin Node to connect back to the blockchain and for you to SSH into the instance.
By the way, I’m still pretty new to GCP, so if this is breaking something I don’t know about… please leave a comment.
I used the search box to jump over to the Compute Engine API to ensure this was enabled.
Under this setting, I clicked Create Credentials to begin creating Service account credentials for Terraform.
With the above settings, click What credentials do I need? I gave the account a name, Compute Admin role, a JSON key-type. This will produces a downloadable JSON file which Terraform will use.
Of course, understand the risk of giving a service account an admin role.
I copied the outputs of this JSON into the accounts.json file listed in the Github repo. I also updated the variable project with the projectid and my IP Address for the variable myip in the variables.tf file. Terraform will create an SSH firewall rule and lock access down to my IP.
Terraform will also create a private key for the instance.
In the directory where the templates have been downloaded, you’ll run the following, and wait for everything to be provisioned:
# set up the directory
terraform init# check resources to be created
terraform plan# when ready, enter yes
When everything is created, you’ll connect to your instance with a similar command:
gcloud compute ssh bitcoin-node --zone us-central1-a --project=<project_id>
You may need to activate your service account so here is the command just in case:
gcloud auth activate-service-account — key-file=credentials/accounts.json
After you have logged in, run this command to see where your node is with syncing:
You can compare the results with the current block count using this:
Don’t forget to check out all the files to see how it all works. Hope this has been helpful. Have a great week. Cheers.