Skip to main content
Welcome to the Terraform CLI introduction. The Terraform command-line interface (CLI) is the primary tool for authoring, provisioning, and managing infrastructure as code. It offers a consistent set of commands that work across providers (AWS, Azure, GCP, and many more) and across operating systems (Linux, Windows, macOS). This consistency simplifies multi-cloud and hybrid infrastructure workflows by providing a single interface to manage cloud resources, on-premises systems, and third-party services.
The Terraform CLI is consistent across providers and platforms, which reduces the learning curve for teams that manage multi-cloud or hybrid environments.
In the sections below you’ll get a concise, practical overview of the essential Terraform CLI workflow: initializing a working directory, creating and reviewing plans, applying changes, and maintaining state. Each command is shown with examples so you can quickly try them in your environment.
A purple presentation slide reading "Using the Terraform CLI" (with a faint "LECTURE" watermark and the Terraform logo). A man in a black shirt stands on the right as if presenting.
Overview of the typical Terraform lifecycle:
  • Initialize a working directory with provider plugins and backend configuration.
  • Author or update Terraform configuration files (.tf).
  • Run a plan to preview changes Terraform will make.
  • Apply the plan to enact changes.
  • Inspect and manage state, and iterate.
Core Terraform CLI commands — quick reference: Example workflow (basic):
  1. Initialize your directory (downloads providers and sets backend):
  1. Preview proposed infrastructure changes:
  1. Apply the planned changes:
  1. When you no longer need the infrastructure:
Best practices and hints:
  • Use terraform plan -out=<file> to save a plan you can review and then apply with terraform apply <file>.
  • Store Terraform state remotely (e.g., S3, Azure Blob, or Terraform Cloud) for collaboration and locking.
  • Run terraform fmt and terraform validate in CI to enforce style and correctness before applying.
Links and resources: Next steps
  • Try the example workflow in a test workspace.
  • Explore provider-specific resources and remote state backends.
  • Use version control and CI to automate terraform fmt, terraform validate, and terraform plan before applying changes.

Watch Video