Like the most of users of Terraform, we have been waiting long for the new release which brings a lot of changes:
Terraform 0.12 is a major update that includes dozens of improvements and features spanning the breadth and depth of Terraform’s functionality. Some highlights of this release include:
1. First-class expression syntax: express references and expressions directly rather than using string interpolation syntax.
2. Generalized type system: use lists and maps more freely, and use resources as object values.
3. Iteration constructs: transform and filter one collection into another collection, and generate nested configuration blocks from collections.
4. Structural rendering of plans: plan output now looks more like configuration making it easier to understand.
5. Context-rich error messages: error messages now include a highlighted snippet of configuration and often suggest exactly what needs to be changed to resolve them.
However, with so many changes under the hood, including a new template engine, there is an official upgrade path you have to follow to move from 0.11.x to 0.12.
So, following the guide, you might encounter the following error:
The reason for that is a change you might have missed which dictates that all modules in Terraform that reside on the filesystem have to be designated with either “./<module>” (relative to current directory) or “../<module>” (outside of current directory).
Therefore, if you have a module defined like that:
You’d have to actually rewrite it to:
Now, if you are like us, and have 100s of modules, maybe this regex can help you to spot all modules which match:
You can use this regex to match all modules and replace them:
In our two major projects, we got 100’s of matches:
After you are done with replacing, run a:
And then you are done with the compatibility changes and can run:
and follow the guide here: https://www.terraform.io/upgrade-guides/0-12.html