2020-10-27 02:15:36 +01:00
|
|
|
---
|
|
|
|
layout: "docs"
|
|
|
|
page_title: "Writing and Modifying Code - Terraform CLI"
|
2021-07-21 23:37:54 +02:00
|
|
|
description: "Learn commands that help validate, format, and upgrade code written in the Terraform Configuration Language."
|
2020-10-27 02:15:36 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
# Writing and Modifying Terraform Code
|
|
|
|
|
2021-01-15 23:13:53 +01:00
|
|
|
The [Terraform language](/docs/language/index.html) is Terraform's primary
|
2020-10-27 02:15:36 +01:00
|
|
|
user interface, and all of Terraform's workflows rely on configurations written
|
|
|
|
in the Terraform language.
|
|
|
|
|
|
|
|
Terraform CLI includes several commands to make Terraform code more convenient
|
|
|
|
to work with. Integrating these commands into your editing workflow can
|
|
|
|
potentially save you time and effort.
|
|
|
|
|
2021-01-19 22:43:01 +01:00
|
|
|
- [The `terraform console` command](/docs/cli/commands/console.html) starts an
|
2020-10-27 02:15:36 +01:00
|
|
|
interactive shell for evaluating Terraform
|
2021-01-15 23:13:53 +01:00
|
|
|
[expressions](/docs/language/expressions/index.html), which can be a faster way
|
2020-10-27 02:15:36 +01:00
|
|
|
to verify that a particular resource argument results in the value you expect.
|
|
|
|
|
|
|
|
|
2021-01-19 22:43:01 +01:00
|
|
|
- [The `terraform fmt` command](/docs/cli/commands/fmt.html) rewrites Terraform
|
2020-10-27 02:15:36 +01:00
|
|
|
configuration files to a canonical format and style, so you don't have to
|
|
|
|
waste time making minor adjustments for readability and consistency. It works
|
|
|
|
well as a pre-commit hook in your version control system.
|
|
|
|
|
2021-01-19 22:43:01 +01:00
|
|
|
- [The `terraform validate` command](/docs/cli/commands/validate.html) validates the
|
2020-10-27 02:15:36 +01:00
|
|
|
syntax and arguments of the Terraform configuration files in a directory,
|
|
|
|
including argument and attribute names and types for resources and modules.
|
|
|
|
The `plan` and `apply` commands automatically validate a configuration before
|
|
|
|
performing any other work, so `validate` isn't a crucial part of the core
|
|
|
|
workflow, but it can be very useful as a pre-commit hook or as part of a
|
|
|
|
continuous integration pipeline.
|
|
|
|
|
2021-01-19 22:43:01 +01:00
|
|
|
- [The `0.13upgrade` command](/docs/cli/commands/0.13upgrade.html) and
|
|
|
|
[the `0.12upgrade` command](/docs/cli/commands/0.12upgrade.html) can automatically
|
2020-10-27 02:15:36 +01:00
|
|
|
modify the configuration files in a Terraform module to help deal with major
|
|
|
|
syntax changes that occurred in the 0.13 and 0.12 releases of Terraform. Both
|
|
|
|
of these commands are only available in the Terraform version they are
|
|
|
|
associated with, and you are expected 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, see the [upgrade
|
|
|
|
guides](/upgrade-guides/index.html) in the Terraform language docs.
|