Terraform Module Outputs

Understand the data source and module outputs in Terraform.

Data sources

Data sources allow us to use inputs from outside the module, and outputs allow us to define what a Terraform module presents as an end result.

Create a Terraform module

To understand Terraform module outputs, we must create a new directory, ltthw_output. We’ll add the afile.txt and output.tf files with some content and finally, we’ll use terraform init to initialize the terraform module.

Notice that the data stanza is new here. This indicates to Terraform that we’re referring to a data source rather than something under its control. Keep that difference in mind as we continue with this lesson.

This Terraform module has a few key differences from the ones we saw in earlier lesson.

Get hands-on with 1200+ tech skills courses.