Data Types: Complex Types

Go through the complex data types in Terraform.

Create a module

The first thing we’ll need to do for this lesson is, create a folder named ltthw_complex_data_types.

Complex types: objects

Complex types allow us to collect variables of different types into a single variable.

If you’ve used object-oriented languages, the object type may look familiar. It allows us to bind together variables of different types to specific names in a way similar to a class in other languages. In this example, we’ve created an object that represents a rectangle. Then we’ve added an output to the file. Then we added an item to the testing.tfvars file, or we could have experimented directly with terraform apply.

Now run the module:

Get hands-on with 1200+ tech skills courses.