Search⌘ K
AI Features

Use of Input Variables

Explore how to define and manage input variables in Terraform configurations. Understand variable types, default values, sensitivity settings, and the order in which Terraform evaluates variable submissions to effectively control your infrastructure deployments.

How to define input variables

Variables are defined in a Terraform configuration. We can supply values for those variables at runtime or set a default value for the variable to use. Terraform requires that we supply a default value for a variable at runtime if we haven’t already done so… Failing to supply a value will cause the relevant command to error out.

At its most basic, a variable can be defined with a name label and without any arguments:

Go (1.6.2)
variable "aws_region" {}

Let’s define some more information about our aws_region:

Go (1.6.2)
variable "aws_region" {
type = string
default = "us-east-1"
description = "The AWS region to use for this configuration"
}

We defined what data type to expect (string) and what value to default to, and we gave a ...