Understanding Data Types

Learn about the different data types for setting variables in Terraform.

Overview

When we create a variable, it’s important to set the data type so that irrelevant inputs won’t be supplied to the variable. Although we can specify a variable that allows any type of value, it’s important to set a type so that a user doesn’t end up providing a string value for a variable that’s supposed to accept numbers.

Terraform variable types

When working with Terraform variables, we can set different variable types, including string, number, bool(ean), list/tuple, map/object. These variable types are classified into two major sub-categories, which are:

  • Primitive types
  • Complex types

Get hands-on with 1400+ tech skills courses.