Catching Errors Early
You can prevent users from entering invalid data by adding validation rules to your variables.
hcl variable "instance_type" { type = string validation { condition = can(regex("^t2.", var.instance_type)) error_message = "We only allow T2 instances for cost control." } }
If someone tries to use a c5.large, the plan will fail immediately with your custom error message.