Plan — preview changes before applying. Apply — execute infrastructure changes.
1# Initialize2terraform init3terraform init -upgrade4terraform init -migrate-state56# Plan7terraform plan8terraform plan -out=tfplan9terraform plan -target=aws_instance.web10terraform plan -destroy11terraform plan -var="environment=staging"1213# Apply14terraform apply15terraform apply tfplan16terraform apply -auto-approve17terraform apply -target=aws_instance.web18terraform apply -parallelism=101920# Destroy21terraform destroy22terraform destroy -target=aws_instance.web2324# Format and validate25terraform fmt -recursive26terraform validate27terraform console2829# Workspace management30terraform workspace list31terraform workspace new staging32terraform workspace select production
Plan output:
Best Practices: