Initialise a Terraform working directory, downloading providers and modules
terraform initPreview the infrastructure changes Terraform will make without applying them
terraform planApply the Terraform configuration to create or update real infrastructure
terraform applyDestroy all infrastructure resources managed by the current Terraform configuration
terraform destroyCheck Terraform configuration files for syntax errors and internal consistency
terraform validateReformat Terraform configuration files to the canonical style
terraform fmtPrint the output values defined in the Terraform configuration
terraform outputList all resources tracked in the current Terraform state file
terraform state listDisplay a human-readable view of the current Terraform state
terraform showImport an existing infrastructure resource into the Terraform state without recreating it
terraform import RESOURCE_ADDRESS RESOURCE_IDGenerate a Terraform execution plan and save it to a file for later use
terraform plan -out=tfplanApply a previously saved Terraform execution plan file
terraform apply tfplanApply a Terraform configuration with an inline variable override
terraform apply -var='project_id=my-project'Create a new Terraform workspace for environment isolation
terraform workspace new WORKSPACE_NAMESwitch to an existing Terraform workspace
terraform workspace select WORKSPACE_NAMEApply Terraform changes to a single specific resource, ignoring others
terraform apply -target=google_compute_instance.webMove a resource to a different address in the Terraform state file without recreating it
terraform state mv OLD_RESOURCE_ADDRESS NEW_RESOURCE_ADDRESSRemove a resource from Terraform state without destroying the real infrastructure
terraform state rm RESOURCE_ADDRESSMark a Terraform-managed resource for forced recreation on the next apply
terraform taint RESOURCE_ADDRESSApply Terraform changes without prompting for interactive confirmation
terraform apply -auto-approveReady to test yourself?
Practice these commands →