Member-only story
Directory and File Structure | Terraform
Terraform Stages
Write
→ Init
→ Plan
→ Apply
→ Destroy
Terraform commands
- terraform init → Used to initialize the Terraform directory
- terraform validate → Validates the configuration files in a directory
- terraform plan → Shows the Terraform plan
- terraform apply → Applies the Terraform code
- terraform destroy → Destroys resources deployed via Terraform
What are Terraform configuration files?
Terraform configuration files are used for writing your Terraform code. They have a.tf
extension and use a declarative language called HashiCorp Configuration Language (HCL) to describe the different components that are used to automate your infrastructure.
Terraform should always be used with a version control system, so all of your Terraform files should be stored inside it.
This allows you to easily track the changes made to the code over time and roll back to a previous version of the configuration.
Terraform directory structure
The Terraform structure is created to manage infrastructure in the form of code, i.e.,IaC
. Managing the Terraform IaC involves.