command branding logo

Terraform

Terraform is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language, or optionally JSON. Terraform manages external resources such as public cloud infrastructure, private cloud infrastructure, network appliances, software as a service, and platform as a service with a code as a configuration file. Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions

Terraform Commands List

Command Name
Command
Command Description
Check Terraform Version
terraform -v
Prints the current version of terraform you are using
Initialize Terraform
terraform init
Initialize Terraform. This is the first command that should be run after writing a new Terraform configuration or cloning an existing one from version control. It is safe to run this command multiple times.
Validate Terraform Configuration
terraform validate
Validates the configuration files in a directory, referring only to the configuration and not accessing any remote services such as remote state, provider APIs, etc.
Plan Terraform Configuration
terraform plan
Generates an execution plan for Terraform. The execution plan shows what Terraform will do when you call apply. By default, the plan command creates a human-readable execution plan. This command is a convenient way to check whether the execution plan for a set of changes matches your expectations without making any changes to real resources or to the state.
Apply Terraform Configuration
terraform apply
The apply command executes the actions proposed in a Terraform plan. This will apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by a terraform plan execution plan.
Destroy Terraform Configuration
terraform destroy
The terraform destroy command is a convenient way to destroy all remote objects managed by a particular Terraform configuration. This effectively destroys all the resources that Terraform knows about.
Show Terraform State
terraform show
The terraform show command is used to provide human-readable output from a state or plan file. This can be used to inspect the current state as Terraform sees it or to inspect the changes that are about to be applied.
Import Terraform State
terraform import
The terraform import command is used to import existing infrastructure into Terraform. This allows you to bring pre-existing infrastructure under Terraform management.
Output Terraform State
terraform output
The terraform output command is used to extract the value of an output variable from the state file. This is useful for extracting information from the state file without having to parse the file manually.
Refresh Terraform State
terraform refresh
The terraform refresh command is used to reconcile the state Terraform knows about (via its state file) with the real-world infrastructure. This can be used to detect any drift from the last-known state, and to update the state file.
Taint Terraform Resource
terraform taint
The terraform taint command is used to mark a resource for recreation. This can be used to force the recreation of a resource, even if it hasn't changed.
Untaint Terraform Resource
terraform untaint
The terraform untaint command is used to remove the taint from a resource. This can be used to allow Terraform to manage a resource again, even if it was previously tainted.
Workspace Terraform
terraform workspace
The terraform workspace command is used to manage workspaces in Terraform. Workspaces allow you to manage multiple states for a single configuration.
Terraform Format
terraform fmt
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style.