Search⌘ K
AI Features

Terraform Variables: Input and Output

Explore how to utilize input and output variables in Terraform using the HashiCorp Configuration Language. Learn to define variable types, assign values, manage resource attributes, and handle configurations for flexible, reusable infrastructure deployments.

Input variables

In programming, we can use variables to store values and customize our application. The same applies to Terraform as we can use input variables to hold values for our arguments. Using input variables allows us to use the same configuration file for different environments by simply tweaking the variables as we need. The different input variable types that Terraform provides include the following:

  • string: This is used for specifying text values, e.g., "name".
  • bool: This is used for specifying boolean values, e.g., true or false.
  • number: This is used for specifying number values, e.g., a port number of 8080.
  • list: This is used to list a range of values, e.g., ["t2.micro", "t2.nano", "t2.small"].
  • map: This is used to list a range of values in a key-pair format. An
...