Terraform Commands
Terraform Commands
Initializes the Terraform working directory. First step before running any Terraform
terraform init Downloads required providers and commands in a new project or after
modules. making changes.
Creates an execution plan showing what Before applying changes to preview and
terraform plan
changes Terraform will make. verify the modifications.
terraform Destroys a specific resource without When you need to selectively remove
destroy -target removing the entire infrastructure. individual resources.
terraform Validates the syntax and consistency of To ensure the configuration is correct
validate Terraform configuration files. before running plan or apply.
terraform Displays the values of output variables To extract useful information (e.g., IPs,
output from the last apply or plan. endpoints) after applying infrastructure.
terraform Imports existing resources into Terraform When you need to bring external
import state. resources under Terraform management.
Updates the state file with the latest If the state file and real infrastructure are
terraform
information from the actual out of sync (e.g., manual changes were
refresh
infrastructure. made).
terraform Lists all providers used in the When you need to see what cloud
providers configuration. services or providers are required.
terraform Releases a state lock if the lock was left When a lock needs to be manually
unlock by an interrupted process. released.