Everyone has coding styles, but enforcing a standardized and commonly readable style is the key for a smooth collaborative team work. That's why Terraform has a command to ensure both format and style are all right.
I encourage readers to use it extensively, and even integrate it in Continuous Integration (CI) systems and in Makefiles.
To step through this recipe, you will need the following:
A working Terraform installation
An Internet connection
We'll intentionally write a simple Terraform code with non-standard style and with an error (a missing variable). This will help us manipulate the various tools Terraform offers to ensure the most consistent and homogenous code, so we can achieve more quickly a better quality and a higher level of standardization of our code.
Let's write a provider for AWS like this in provider.tf
(deliberately on one line):
provider "aws" { region = "${var.aws_region}" }