Until an add-on will be available, you can run this:
This will recursively search the current working directory for any folders that contain Terragrunt configuration files and run the equivalent of terraform fmt on them.
terragrunt hclfmt
Or this, to format a sepcific file:
terragrunt hclfmt --terragrunt-hclfmt-file /path/to/hcl/file
https://terragrunt.gruntwork.io/docs/getting-started/configuration/
Take it one step further:
- Install Run on Save -
https://marketplace.visualstudio.com/items?itemName=emeraldwalk.RunOnSave
- Add the follwoing config to settings.json
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.hcl$",
"cmd": "terragrunt hclfmt --terragrunt-hclfmt-file ${file}"
}
]
}
Now every time you will save .hcl
file, the terragrunt hclfmt
command will run and reformat that file.
Note - if you have auto save enabled, it will run automatically every time you make a change to .hcl
file.