Errors & warnings while upgrading Terraform 0.12 to 0.14

Upgrading Terraform logo

While consolidating a handful of my sites from various hosting providers, I wanted to add those domains to my Cloudflare account to protect them from malicious traffic & improve their performance.

At the time this post was written, 0.14 is the latest version – but I was still on v0.12 which I had installed with a simple brew install terraform command. As I typically do, I ran brew update && brew upgrade and voila! I was on the latest version, having skipped v0.13:

However, I learned the hard way that Terraform only supports upgrading to each release in order, and they don’t recommend skipping versions. If you are upgrading from earlier versions, it is extremely important to follow the Upgrade Guides!

Here’s a couple examples of the issues I encountered …

Error: Failed to query available provider packages

Upon skipping the 0.13 major release, I found that third-party Terraform providers (those developed by various cloud providers, not by Hashicorp) were no longer working.

So after upgrading Terraform & adding the Cloudflare provider block, I typed terraform init in my new project and got the following error:

Notice that penultimate paragraph about upgrading directly from v0.12 to v0.14? It’s great that Hashicorp built such a helpful error message into their CLI, and following it solved my issues completely. However, I’d strongly prefer fewer breaking changes, or better tools/codemods to help users update directly to later versions without the friction of upgrading to each release in between.

Looking at the 0.12 → 0.13 Upgrade Guide, you’ll notice a section about Explicit Provider Source Locations which describes the new hierarchical namespace structure for providers. My existing hashicorp/cloudflare provider no longer existed, because the Cloudflare provider is not published by hashicorpthe new name is cloudflare/cloudflare, and it must be in the required_providers nested block inside the terraform configuration block.

So I created a new main.tf file and added the appropriate provider config:

Notice the version argument, which I added to ensure I’m using the latest

Warning: Interpolation-only expressions are deprecated

I also received a deprecation warning upon running terraform init in my new project.

Here’s what that warning looked like:

This warning is telling me that using interpolation syntax, e.g., ${someVar.someThing}, is no longer supported. Just remove the bracket syntax and leave the inner expression, and you’re good to go.

Conclusion

There were a few other issues I ran into, but they were easily solvable with Startpage & Stack Overflow.

I’m out of time for writing this week, so best of luck to ya!

Author: Grant Norwood

Designer of things you click. Vegetable rights activist. Volunteer with tiny humans. Austin-ish, Texas.

People describe me as a rad web developer, product manager, solutions architect, public speaker, volunteer, and non-profit board member.

Did you know you can leave a comment?

%d bloggers like this: