skip to content
Alvin Lucillo

Terraform variables

/ 1 min read

💻 Tech

Maintaining configuration values across environments require dynamic values, which can be achieved with .tfvars file.

First, declare the variable definition:

vars.tf

variable "personne" {
  type = object({
    nom          = string
  })
}

Then, define the values for that variable:

dev.tfvars

personne = {
   nome = "françois"
}

prod.tfvars

personne = {
   nome = "pierre"
}

Use it with terraform commands like: terraform plan --var-file=.dev.tfvars