Terraform
Write and modify Terraform configuration from the CLI
This topic provides an overview of the Terraform CLI commands you can use to develop, format, and validate your Terraform configuration.
Introduction
The Terraform language is Terraform's primary user interface, and all of Terraform's workflows rely on configurations written in the Terraform language.
Workflows
Terraform CLI includes several commands to make Terraform code more convenient to work with. You can integrate the following commands into your editing workflow to test expressions and format and validate your configuration syntax:
- The - terraform consolecommand starts an interactive shell for evaluating Terraform expressions, to quickly verify that a particular resource argument results in the value you expect.
- The - terraform fmtcommand automatically rewrites Terraform configuration files to a canonical format and style, so you don't have to waste time making minor adjustments for readability and consistency. The- terraform fmtcommand works well as a pre-commit hook in your version control system.
- The - terraform validatecommands validates the syntax and arguments of the Terraform configuration files in a directory, including argument and attribute names and types for resources and modules. The- planand- applycommands automatically validate a configuration before performing any other work. Running- validateisn't a crucial part of the core workflow but can be very useful as a pre-commit hook or as part of a continuous integration pipeline.
- The - 0.13upgradeand- 0.12upgradecommands modify the configuration files in a Terraform module automatically to help deal with major syntax changes that occurred in the 0.13 and 0.12 releases of Terraform. Both commands are only available in the Terraform version they are associated with. Make sure to upgrade older code to be compatible with 0.12 before attempting to make it compatible with 0.13. For more detailed information about updating code for new Terraform versions, refer to the upgrade guides.