July 17, 2019

Upgrade Terraform to 0.12

So, this is really easy to do. Of course, the level of success you will have using the provided upgrade tool will ultimately depend on the complexity of your code.

The official upgrade instructions can be found here. I ran into only one issue in one of my builds that required manual intervention; when specifying a source for a module, you'll need to use the current directory syntax "./" instead of just calling it directly:

After that, I was able to complete the upgrade by running the following in the parent directory:

$ terraform init
$ find . -name '*.tf' -printf "%h\n" | xargs -n1 terraform 0.12upgrade -yes
$ terraform plan
$ terraform apply

Thankfully, everything went smoothly for me, but I highly recommend auditing your current Terraform infrastructure state and syncing the state and config files before performing the upgrade. It should go without saying, but commit the changes to your repo before the upgrade so you have a backup in case something goes wrong.