What is the purpose of terraform.tfvars files?
terraform.tfvars files provide values for your declared variables, keeping configuration separate from the variable definitions. This allows you to have different values per environment without modifying the core modules.
# variables.tf — defines the variable
variable "instance_type" {
description = "EC2 instance type"
type = string
}
# production.tfvars — provides the value
instance_type = "c5.2xlarge"
# development.tfvars
instance_type = "t3.micro"
Never commit .tfvars files containing sensitive values to Git. Use .gitignore and pass sensitive values via environment variables (TF_VAR_*) in CI/CD.