Terraform v0.12 overhauls language syntax & improves functionality
The latest release of HashiCorp’s Terraform is here. Version 0.12 overhauls the language, adding several improvements and changes. New features include first-class expression syntax, a generalized type system, iteration constructs, and more. Follow the upgrade guide to begin.
On May 22, 2019, the Terraform team at Hashicorp announced the latest update: Terraform 0.12. Version 0.12 includes some new features and several improvements focused on config language improvements.
This update overhauls the language syntax. From the 0.12.0 changelog:
The focus of v0.12.0 was on improvements to the Terraform language made in response to all of the feedback and experience gathered on prior versions. We hope that these language improvements will help to make configurations for more complex situations more readable, and improve the usability of re-usable modules.
However, an overhaul of this kind inevitably means that 100% compatibility is not possible. The updated language is designed to be broadly compatible with the 0.11 language as documented, but some of the improvements required a slightly stricter parser and language model in order to resolve ambiguity or to give better feedback in error messages.
With v0.12, previous limitations of Terraform’s syntax and language engine have been altered.
It also adds several requested features from the community.
Some of the highlights added to Terraform 0.12 include:
- First-class expressions: This new syntax change integrates expressions. Use expressions directly as argument values instead of using string interpolation syntax.
forexpressions: Create complex type value via transforming another complex type value
- Nullable argument values: Leave an argument value unset
- New built-in functions:
- Improved error messages: Error messages now includes additional contextual info and suggests actions to take for common issues.
dynamicblocks: Dynamically generates nested configuration blocks for resources.
- New plan renderer: Re-structures plan output and integrates the new type system
- Generalized type system: Richer type system introduces new options for passing objects and other values between modules.
- Improved JSON-based variant syntax: See the notes and changes here.
- Various bug fixes
See the full list of what’s new in the changelog on GitHub.
Upgrading to the latest version
Upgrading to the new release? Follow the upgrade guide for in-depth steps, commonly encountered issues, and the pre-upgrade checklist. As previously mentioned in the changelog, the overhaul in this new release can create compatibility issues.
The changelog also presents incompatibilities and notes for the update.
For further learning, HashiCorp provides various lessons about building infrastructure in AWS, migrating to the cloud from local state storage, and more.