Using Terraform CLI, how do you reformat your Terraform configuration files in the standard style?
Experience Level: Junior
Tags: Terraform
Answer
Run the following command:
terraform fmt
When you execute the command, it will automatically reformat (modify) all files that didn't meet the standard style. The names of modified files will be displayed.
Note that without providing additional parameter -recursive only the files in the current folder will be processed. Files in subfolders will be skipped.
Related Terraform job interview questions
What does command 'terraform fmt -check' do?
Terraform JuniorUsing Terraform CLI, how do you reformat all files to meet the standard style including the files in subfolders?
Terraform JuniorWhat format does variable definition file use in Terraform?
Terraform JuniorHow can you provide variables using file to Terraform CLI without the need to specify the name of the variable definition file?
Terraform JuniorHow can you pass variables to Terraform CLI console command?
Terraform Junior