Loading...
Loading...
Master the core Terraform workflow: init, plan, apply, and destroy
Terraform has a standard four-step workflow:
terraform init → terraform plan → terraform apply → terraform destroyPrepares your working directory:
terraform initCreates an execution plan — shows what will happen without actually doing it:
terraform planOutput:
Terraform will perform the following actions:
+ create azurerm_resource_group.main
+ create azurerm_virtual_network.mainThe + means create, - means destroy, ~ means modify in-place.
Executes the plan — creates, updates, or deletes resources:
terraform applyTerraform will show you the plan and ask for confirmation. To auto-approve:
terraform apply --auto-approveDestroys ALL resources managed by your configuration:
terraform destroyAfter apply, Terraform creates a terraform.tfstate file. This file maps your config to real resources. It contains sensitive information and should be stored remotely for team use.
Write the four Terraform commands in order for a new project. For each command, add a comment (#) explaining what it does.
# terraform init - Download providers and modules export TF_INIT="terraform init" # terraform plan - Preview infrastructure changes export TF_PLAN="terraform plan" # terraform apply - Create or update resources export TF_APPLY="terraform apply" # terraform destroy - Remove all managed resources export TF_DESTROY="terraform destroy"