Search⌘ K

Exploring Terraform Variables

Explore how Terraform variables function as customizable parameters for Azure Kubernetes Service clusters. Understand the purpose of variable types, default values, and how they influence cluster scalability and configuration flexibility in infrastructure as code.

Viewing variables in Terraform

Generally speaking, entries in Terraform definitions are split into four groups. We have:

  • Provider
  • Resource
  • Output
  • Variable

That’s not to say that there aren’t other types (there are), but those four are the most important and most commonly used ones. For now, we’ll focus on variables and leave the rest for later.

Note: All the configuration files we’ll use are in the file subdirectory. We’ll pull them out one by one and explore what they’re used for.

Let’s take a quick look at the file that defines the variables.

Output description

Shell
variable "region" {
type = string
default = "eastus"
}
variable "resource_group" {
type = string
default = "devops-catalog-aks"
}
variable "cluster_name" {
type = string
default = "docatalog"
}
variable "dns_prefix" {
type = string
default = "docatalog"
}
variable "k8s_version" {
type = string
}
variable "min_node_count" {
type = number
default = 3
}
variable "max_node_count" {
type = number
default = 9
}
variable "machine_type" {
type = string
default = "Standard_D1_v2"
}
...