Terraform CLI, Providers, Registry and State
What the Terraform CLI does
The Terraform CLI (command-line interface) is the executable you run in a terminal. It reads configuration files, calculates proposed infrastructure changes and coordinates providers to carry out approved operations. A provider is an integration that implements resource types. Terraform also keeps state, a record that connects managed objects to their configuration. You can learn these pieces without connecting to a cloud account.
Example: label the parts of a fictional deployment
Imagine a team describing a small web server. Their configuration says what they want. The Terraform CLI interprets that description. A suitable provider knows how to interact with the hosting service. The registry is a place to discover distributed providers and reusable configuration packages. State records the association between the declared server and the object managed by Terraform. The backend determines how state is stored; some backends also support remote operations.
This is a conceptual flow, not a deployment recipe:
Configuration -> Terraform CLI -> Provider -> Hosting service | v Backend -> StateRegistry -> provider packages (when installation is needed)The registry is not the hosting service, and a registry package is not a running server.
Configuration, state and backend are different
Configuration is the intended setup. State records managed resource identities and stored values. A backend is the storage mechanism for that state. Terraform normally uses a local backend when no alternative is configured. If a teammate changes a managed object outside Terraform, state may not yet reflect the change. Terraform can refresh its view during planning, subject to options and provider behavior. Protect state because it can contain sensitive values; do not use it as a public example or edit it by hand to fix an ordinary configuration mistake.
A provider does not always mean an external download
Many providers are separate executable plugins. They supply resource-specific behavior, so their versions matter independently of the CLI version. Terraform also ships a built-in provider with the address terraform.io/builtin/terraform. The terraform_data resource can hold synthetic values in state without provisioning a remote server. Our first configuration will use this built-in resource, not a separately installed plugin. A reusable module is configuration, whereas a provider implements integrations and resource behavior; modules will be covered later.
Local CLI, HCP Terraform and OpenTofu
With the local CLI, you can run Terraform on your own computer. HCP Terraform is a hosted collaboration and workflow service that can manage state and execute runs remotely, depending on workspace configuration. Terraform Enterprise is a separately licensed self-hosted product. OpenTofu is a related but independently released infrastructure-as-code tool, invoked as tofu. Similar configuration does not guarantee equivalent features or safe state migration. The core path here uses Terraform CLI only, with no hosted account. Do not substitute another tool in an existing project without checking compatibility and making a migration plan.
Example: trace a change without applying it
A fictional configuration changes a server label from demo to training. The CLI asks the relevant provider to help determine a change, using configuration and available state information. A plan describes the proposed actions. A reviewer examines it before deciding whether to apply. The backend stores the resulting state after operations that update it. Whether the label can be changed in place or requires replacement depends on the resource schema and service behavior; the label alone cannot tell you.
Common mistakes and next step
Do not confuse downloading a provider with creating a resource, or a backend with the provider that manages a server. Installing Terraform does not create cloud resources. However, running Terraform against unfamiliar configuration can contact external services or start remote workflows. First identify the directory, dependencies and execution environment. Practice labeling a fictional deployment, then prepare a clean local workspace.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Terraform CLI, Providers, Registry and State — knowledge check
Check the concepts and decisions introduced in this lesson.
Which component implements operations for a particular hosting service?
What is the difference between state and a backend?
A package appears in a registry. What does that establish?
Which statement describes the built-in terraform_data resource?
A colleague proposes using OpenTofu for an existing Terraform project. What is a sensible first step?