Difference between revisions of "Terraform fmt"

From wikieduonline
Jump to navigation Jump to search
 
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{lowercase}}
 
{{lowercase}}
<code>terraform fmt</code> command is used to rewrite Terraform configuration files to a canonical format and style.
+
<code>terraform fmt</code> command is used to rewrite Terraform configuration files to a canonical format and style. <ref>https://www.terraform.io/docs/cli/commands/fmt.html</ref>
* https://www.terraform.io/docs/cli/commands/fmt.html  
 
  
  [[terraform fmt -diff]]
+
[[terraform fmt --help]]
 +
  [[terraform fmt -diff]]             Changes and display diffs of formatting changes
 
  [[terraform fmt -check]]
 
  [[terraform fmt -check]]
 +
[[terraform fmt -recursive]]
 +
[[terraform fmt -write -recursive]]
 +
[[terraform fmt -check -recursive -diff]]
  
 
== Examples ==
 
== Examples ==
[[terraform]] fmt
 
(no output)
 
  
 +
Scan .tf files in your current directory:
 +
:<code>[[terraform]] fmt</code>
 +
:<code>(no output)</code>
 +
 +
 +
<code>main.tf</code> has been formated:
 
  terraform fmt
 
  terraform fmt
 
  [[main.tf]]
 
  [[main.tf]]
Line 17: Line 24:
 
  [[variables.tf]]
 
  [[variables.tf]]
  
* <code>[[terraform fmt -check]]</code>
+
[[terraform fmt -check]]
:(no output)
+
(no output)
 +
 
 +
:<code>[[terraform]] fmt FileToScan.tf</code>
 +
:FileToScan.tf
  
* <code>[[-diff]]</code> - Display diffs of formatting changes
+
== Activities ==
 +
* Use <code>[[vimdiff]], [[icdiff]]</code> or [[set list]] in vim to identify [[lines with a single space]] on it.
  
 
== Related commands ==
 
== Related commands ==
* <code>[[go fmt]]</code> and [[import "fmt"]]
 
 
* <code>[[cfn-lint]]</code>
 
* <code>[[cfn-lint]]</code>
* [[Linter]]
 
 
* <code>[[terraform validate]]</code>
 
* <code>[[terraform validate]]</code>
 
* <code>[[terraform apply]]</code>
 
* <code>[[terraform apply]]</code>
 
* [[Terraform Style Conventions]]
 
* [[Terraform Style Conventions]]
 +
* <code>[[terragrunt fmt]]</code>
 +
* <code>[[Warning: Interpolation-only expressions are deprecated]]</code>
 +
* <code>[[.pre-commit-config.yaml]]</code>
 +
* <code>[[terraform --version]]</code>
 +
* <code>[[set list]]</code>
 +
* [[vimdiff]]
 +
* [[icdiff]]
  
 
== See also ==
 
== See also ==
* {{fmt}}
+
* {{terraform fmt}}
* {{terraform cmd}}
 
* {{terraform}}
 
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 11:51, 30 May 2024

terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. [1]

terraform fmt --help
terraform fmt -diff              Changes and display diffs of formatting changes
terraform fmt -check
terraform fmt -recursive
terraform fmt -write -recursive
terraform fmt -check -recursive -diff

Examples[edit]

Scan .tf files in your current directory:

terraform fmt
(no output)


main.tf has been formated:

terraform fmt
main.tf
terraform fmt 
main.tf
variables.tf
terraform fmt -check
(no output)
terraform fmt FileToScan.tf
FileToScan.tf

Activities[edit]

Related commands[edit]

See also[edit]

  • https://www.terraform.io/docs/cli/commands/fmt.html
  • Advertising: