Upgraded my website infrastructure to OpenTofu

Oct 9, 2023ยท

2 min read

My personal cloud infrastructure is hosted in Google Cloud Platform. I serve up mostly static content for 12 domains, behind a global URLMap load-balancer. Each domain is routed to its own bucket. Each domain's content is stored in a GCP Git repo, and acloudbuild.yaml file in each repo uses CloudBuild to build and deploy to the matching bucket. All I have to do it is edit, commit and push.

Being an avid fan of Terraform since 2019, of course I used it to build, maintain and deploy it all, but I was couple major revisions behind the latest.

I've been meaning to try OpenTofu since the Linux Foundation announced the fork.

Honestly, it's amazing to me that Hashicorp tried to re-license Terraform, because open-source communities typically respond exactly the same way every time it happens (Hudson/Jenkins, MySql/MariaDB, OpenOffice/LibreOffice, XFree86/X.org). Maybe the decision-maker just isn't old enough to know this history. ๐Ÿ™„

Anyway, I replaced the terraform invocations in my deployment script with tofu. I had to run tofu -upgrade at first, to update the terraform.tfstate file. After that, all seemed to be smooth. The first tofu apply command wanted to add a bunch of stuff to each of my bucket's output, but these seem to be related to a newer version of the google provider. Here's the one for the bucket that has this blog's content:

Plan: 0 to add, 11 to change, 0 to destroy.

Changes to Outputs:
  ~ buckets = [
          ~ "timcod.es"            = {
              + autoclass                   = []
              + custom_placement_config     = []
              + effective_labels            = {}
                id                          = "timcod.es"
                name                        = "timcod.es"
              + public_access_prevention    = "inherited"
              + terraform_labels            = {}
                # (18 unchanged attributes hidden)

I'll update this post with any issues or observations I make with this multi-domain hosting setup.

So far, so good... IT JUST WORKS! (the ultimate brag in Open Source, IMHO).