DELAPARRA
Index
Color
NL
Category: Terraform

fmt

Explained by Updated

What is fmt?

fmt: Rewrites files to the canonical HCL style (indentation, alignment). Run it in CI with -check to enforce formatting. terraform fmt rewrites Terraform files into the standard formatting: indentation, alignment of equal signs and spacing. terraform fmt -recursive does it for all subfolders too. Consistent formatting makes reviews easier. Changes show up as real changes instead of reshuffled whitespace, and everyone's code looks the same.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about fmt

What should you keep in mind with fmt?

Run it in CI with -check, which fails the pipeline when a file is not formatted without changing anything. Most editors can also run it automatically on save through the Terraform extension. Like code formatters for other languages, it settles style questions once, so nobody spends review time on them. Pair it with terraform validate for a quick check that the configuration is valid before planning.

What does an example of fmt look like?

terraform fmt -recursive -check

At a glance

CategoryTerraform
Explained by
Updated

More Terraform terms

All terms starting with F

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.