Terraform Apply
terraform apply -auto-approve
Terraform Plan
terraform plan -out plan.out
-> save the planterraform show -json plan.out > plan.json
-> write the plan as json
Terraform State
terraform show -json | jq -C | less -R
-> show the state with pretty colorsterraform state list
-> show resources in the stateterraform plan -replace="<resource_name>"
-> replaces resources from the state file (v0.15.2+ - older versions taint/untaint)terraform state mv
-> move statesterraform plan -refresh-only
-> configuration drift between infra and the state(check changes)terraform apply -refresh-only
-> apply changes from infra to the state file.- Resource Lifecycle
reate_before_destroy = true
prevent_destroy = true
ignore_changes
- For changes outside the Terraform workflow that should not impact Terraform operations
Terraform Import
terraform import -var-file <vars>.tfvars <resource> <resource_id>