What is terraform.tfvars file?
Answer
The terraform.tfvars file provides values for input variables. Terraform automatically loads it if present in the working directory. Format: plain variable assignments: region = "us-east-1"\ninstance_type = "t3.micro"\nallowed_cidrs = ["10.0.0.0/8", "192.168.0.0/16"]. For different environments, create named files: dev.tfvars, prod.tfvars. Load explicitly: terraform apply -var-file="prod.tfvars". Files ending in .auto.tfvars are loaded automatically without explicit flags. Do not commit sensitive tfvars files to Git — add *.tfvars to .gitignore (except non-sensitive example files). For CI/CD, pass sensitive values via environment variables (TF_VAR_*) or secret management systems. Provide a terraform.tfvars.example with placeholder values for documentation.