Terraform in details

Here we can go through terraform features and other aspects of terraform

Terraform variables validation

we have applied the validation parameter for the resource group name, if the given name won't meet the desired conditions it will through error.

variable "rg_name" {
    type = string
    default = "rg-13"

    validation {
      condition = length(var.rg_name) > 3 && substr(var.rg_name, 0, 3) == "rg-"
      error_message = "resource group must start with \"rg-\" "

when you try to run terraform plan

terraform plan -out tfplan -var rg_name="tfrg"