To describe infrastructure without scripting every deployment step, write the desired end state in HashiCorp Configuration Language (HCL). Terraform uses its own flavor of HCL, with Terraform-specific resources and functions. The format is designed to be readable by people who are new to it. section 1.2.1
Terraform reads configuration files to construct a dependency graph. Its usual workflow is init, plan, apply: obtain needed providers or modules, compare the desired configuration with the workspace, then carry out the plan. HCL describes what should exist; the plan determines the actions. section 1.7 section 11.2
Listing 5.6 Variable file with HCL
# Production Data #1 vpc = "vpc-01234567890abcdef" #2 num_instances = 2
A production variable file shows a narrower use of HCL: commented, key-equals-value assignments for a VPC identifier and instance count. Unlike a full configuration, a variable file has no blocks and accepts literal values only—not functions or transformations. section 5.4.3
Use a .tfvars file with a command such as terraform plan -var-file=production.tfvars, or name it terraform.tfvars or *.auto.tfvars for automatic loading. The extension matters: .tfvars.json denotes JSON instead. JSON is also an alternative for entire Terraform configurations, especially when software generates them; HCL remains the more readable choice for human-written files. section 5.4.3 section 11.2
HCL can also express native Terraform tests, avoiding a second testing language such as Go. Check version compatibility before relying on that framework: it first appeared in Terraform and OpenTofu v1.6 and cannot test older versions. section 9.1.3


