You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Variables make your Terraform configuration flexible and reusable. Outputs expose values from your infrastructure for use by other configurations or scripts. This lesson covers input variables, output values, local values, and variable files.
An input variable is declared with the variable block:
variable "region" {
description = "The AWS region to deploy into"
type = string
default = "eu-west-2"
}
variable "instance_count" {
description = "Number of instances to create"
type = number
default = 1
}
variable "enable_monitoring" {
description = "Whether to enable detailed monitoring"
type = bool
default = false
}
| Argument | Required | Purpose |
|---|---|---|
description | No (recommended) | Documents the variable's purpose |
type | No (recommended) | Constrains the variable type |
default | No | Default value if none is provided |
validation | No | Custom validation rules |
sensitive | No | Hides the value in plan output |
nullable | No | Whether the variable can be null |
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.