This blog post will show you how to format an existing Terraform code with a well readable format and indentation.
The Terraform CLI tool comes with a very cool feature that takes an existing code and formats it with the correct indentation.
To try, open an existing Terraform folder with a .TF file and run the following code:
To fix multiple files you can run the following command at the root of your Terraform configuration files where you have multiple folders and files.
terraform fmt -recursive
To preview the the changes without making any changes you can run the following command.
terraform fmt -check