In this recipe, we have learned that the terraform fmt command executed in its most basic way, that is, without any additional options.
This default command indents the Terraform file code, which is at the root of the current folder. We can also execute this command recursively, that is, it can also indent the code in subfolders of the current folder.
To do this, we execute the terraform fmt command with the -recursive option and its output is shown in the following screenshot:
We see that the command has also formatted the main.tf file in the sub folder.
Among the other options of this command, there is also the -check option, which can be added and allows you to preview the files that will be indented, without applying the changes in the file(s).
Finally, it's also possible to automate the execution of this command, because apart from running it manually in a command terminal, as seen in this recipe, we can automate it to ensure that every time we save...