Tinkering with Terraform 0.14 RC1

Now that my environment is entirely updated to use Terraform 0.13, I’ve been keeping an eyeball on the development of Terraform 0.14. Release Candidate 1 (RC1) was published about a week prior to this blog post and contains a litany of improvements. A few things caught my eye: an experimental “concise” diff engine and the ability to mark input variables as sensitive. I tinkered around with both features, along with the new .terraform.lock.hcl file, on my latest Twitch stream.

This post summarizes the highlights and attempts to capture the excitement of seeing a new version being developed!

Quick Reminder: I livestream on technical topics every week on Twitch – come join the adventure! Drop a follow and enable notifications to stay current.

Terraform 0.14 Release Candidate Download

I suggest following the Terraform GitHub repository and enabling notifications when new releases are published. This provides visibility of new stable and development releases.

From there, all compiled Terraform releases can be found here. The Terraform 0.14 RC1 build is nested within that directory here. Alternatively, just use Scoop if you’re on Windows – thanks for the tip, Loren Gordon! ๐Ÿ™‚

I apparently love doing things the hard way and maintain different aliases in my profile.ps1 file for unique release trains of Terraform. In this case, I use tf14 as an alias pointed to the renamed terraform14rc1.exe executable. The plan is to switch over to a proper package manager in the near future.

Experimental Concise Diff Renderer

Tinkering with the concise diff renderer requires no effort. In the livestream, I copied over code from my Certified Kubernetes Administrator study guide as a baseline. This code constructs an AWS Launch Template and then deploys an Auto Scaling group with a user-defined quantity of nodes. I’ve talked more about this code in the AWS Launch Template with Dynamic User Data post.

I deployed the configuration to a new environment using Terraform 0.14. The process was snappy as usual. Then, I changed the quantity of nodes within the Auto Scaling group from one to two. Running tf14 plan presented a crisp new experience!

The first major change is in how Terraform refreshes resources. This is now done “just in time” as stated in this pull request. This is awesome for those of us who commonly had complex configurations that required a cringe-inducing -refresh=false in order to succeed. Also, the new process is incredibly fast! ๐ŸŽ‰

The second major change is in how the diff renderer displays changes. As highlighted by the yellow box, many of the attributes contained by the aws_autoscaling_group did not change due to the new plan. Rather than flood the console with static attribute values, the diff renderer shows a “concise” output. Consider how useful this will be for large Terraform configurations with dozens (or more) resources!

It’s worth noting that, for now, the feature can be toggled off by setting an environmental variable named TF_X_CONCISE_DIFF to zero (0). This worked as expected and the normal flood of attributes are displayed regardless of their future state.

Sensitive Input Variables

This is where I had mixed success. I was reading this pull request on how to mark variable blocks as being sensitive by adding sensitive = true. This supposedly requires experiments = [sensitive_variables] in a Terraform block to enable, which throws an error stating that the experiment is not valid. Bummer. I suppose that perhaps this mode is no longer considered experimental?

Marking a variable block as sensitive worked so long as it was not being used elsewhere in the config.

variable "instance-name" {
  description = "The name of the EC2 instance"
  type        = string
  default     = "cka-node"
  sensitive   = true

In the case of the instance name variable, which is used to name the Launch Template, a sensitive variable would throw an error.

Error: .name: value has marks, so it cannot be serialized

This, too, has supposedly been resolved with a pull request. ๐Ÿ˜

This is the fun part about tinkering with the release candidate – it’s like seeing the future unfold with numerous folks all contributing ideas and fixes to make the future better.

Next Steps

Please accept a crisp high five for reaching this point in the post!

If youโ€™d like to learn more about Infrastructure as Code, or other modern technology approaches, head over to the Guided Learning page.

If thereโ€™s anything I missed, please reach out to me on Twitter or catch my next Twitch live stream. Cheers! ๐Ÿ™‚