What are Terraform Variables?

Answer

Terraform variables make configurations reusable and parameterizable. Declare input variables: variable "region" { type = string; default = "us-east-1"; description = "AWS region to deploy in" }. Use: provider "aws" { region = var.region }. Set variable values: tfvars files: create terraform.tfvars or prod.tfvars. Environment variables: TF_VAR_region=us-east-2. Command line: terraform apply -var="region=us-west-2". Types: string, number, bool, list(string), map(string), object({ ... }), any. Mark sensitive variables with sensitive = true to prevent them from appearing in plan output and logs. Use validation blocks to enforce allowed values.