Video Thumbnail for Lesson
3.3: Terraform Plan, Apply, Destroy

Terraform Plan, Apply, Destroy

The Terraform commands "plan," "apply," and "destroy" are essential for managing your infrastructure and making sure your desired state matches the actual state of your resources.

Terraform Plan Command:

  • Compares the desired state (Terraform configuration) with the actual state (Terraform state file)
  • Identifies any discrepancies between the two states
  • Outputs the differences and the actions needed to reconcile the states
Terraform plan visual

Terraform Apply Command:

  • Executes the actions identified in the Terraform Plan command
  • Creates, modifies, or deletes resources as needed to match the desired state
  • Updates the Terraform state file to reflect the changes
Terraform plan visual

Terraform Destroy Command:

  • Removes all resources associated with the Terraform configuration
  • Use with caution, as it permanently deletes resources
  • Typically used to clean up resources at the end of a project or example
Terraform plan visual

Understanding these commands is crucial for managing your infrastructure and ensuring your desired state aligns with the actual state of your resources.

Always exercise caution when using the "destroy" command to avoid accidentally deleting important resources.