Terraform has a built-in formatter and I somehow went years without using it. It rewrites .tf files into the canonical style, including the = alignment I had been doing by hand.

terraform fmt

The flags that make it useful:

terraform fmt -recursive   # include subdirectories, not just the current one
terraform fmt -check       # exit non-zero if anything would change
terraform fmt -diff        # show what it would change

-check is the one worth wiring into CI. It fails the build on unformatted config without rewriting anything.