โ Terraform Associate Exam Practice learning pathTerraform Associate Exam Practice ยท Module 4 of 10
Variables, outputs and expressions
Making configuration flexible.
๐ Key ideas
- Input variables (variable blocks) parameterise configs; set via defaults, tfvars files, -var flags or TF_VAR_ environment variables.
- Variable types: string, number, bool, list, map, set, object and tuple; validation blocks enforce rules.
- Outputs expose values after apply and pass data between modules.
- Mark sensitive values with sensitive = true to hide them in output.
- Expressions: interpolation, conditionals (condition ? a : b), for expressions, count and for_each.
๐ก Real-life example: Like a form template: the same form, filled with different names and dates each time.
Input variableParameter supplied to configuration
Output valueValue exposed after apply
tfvars fileFile assigning variable values
for_eachCreates instances from a map or set