← Terraform & Infrastructure as Code learning path
Terraform & Infrastructure as Code · Module 3 of 10

Variables, outputs and locals

Make configurations reusable.

📖 Key ideas

  1. Input variables: variable "region" { default = "ap-south-1" }.
  2. Set values with terraform.tfvars, -var, or environment variables (TF_VAR_name).
  3. Outputs show values after apply: output "url" { value = ... }.
  4. Locals hold computed values for reuse.
  5. Mark secrets as sensitive = true.
💡 Real-life example: Variables are blanks in a form; outputs are the receipt you get after submitting.
VariableInput parameter
OutputValue shown after apply
LocalNamed computed value
tfvarsFile setting variable values