Les 4 commandes fondamentales du workflow Terraform, à exécuter dans cet ordre.


Le workflow standard

1. terraform init     ← télécharge providers, modules, configure backend
2. terraform plan     ← calcule les changements (ne modifie rien)
3. terraform apply    ← applique les changements
4. terraform destroy  ← détruit tout (optionnel)

Notes détaillées

CommandeRôle
terraform initInitialiser le projet (providers, modules, backend)
terraform planPrévisualiser les changements (dry-run)
terraform applyAppliquer les changements
terraform destroyDétruire l’infrastructure
terraform taint⚠️ Forcer la recréation d’une ressource (déconseillé → -replace)

Workflow CI/CD complet

terraform init -input=false -backend=true
terraform fmt -check -recursive
terraform validate -backend=false
terraform plan -out=plan.tfplan -var-file=prod.tfvars
terraform apply plan.tfplan

En relation avec