Data Types: Collection Types

Define and execute simple and collection data types in Terraform.

Underpinning Terraform is a configuration language called HCL, which stands for HashiCorp Configuration Language. As the name suggests, it’s a language designed for configuration created by HashiCorp, the same company that created Terraform itself.

Like other configuration languages, HCL is declarative. HCL also shares some characteristics with more robust programming languages, and in this lesson, we’ll look at Terraform’s data types.

This lesson is somewhat limited to only covering data types in HCL. Most of this you could probably figure out yourself as you continue to learn Terraform if you’re already proficient in other languages. However, you can return to this lesson whenever you feel like it as a place for revision.

It’s also helpful to have a proper grounding in data types if we start using Terraform’s looping capabilities, which we look at later in the course. Finally, understanding data types in HCL is also frequently useful when debugging Terraform scripts.

Simple data types

First, we create a folder named ltthw_data_types with a vars.tf file to store some examples of the basic data types available in Terraform. Then we create some output values to match in output.tf like so:

Get hands-on with 1200+ tech skills courses.