6. Outputs
Outputs are a way to print data to the shell after a Terraform run, or to pass data between modules. They are often used to show values to the user which would otherwise be hidden as part of troubleshooting.
Syntax
In its simplest form, and output looks like this
output "property_id" {
value = akamai_property.my_property.id
}
Here, the value is inferred from a resource (which is the norm), but if you wish the value could simply be a string, or a combination of both.
Outputs can also contain the keywords description
and sensitive
. A description
is purely to help the reader understand the purpose of the output, by sensitive
can be used to suppress values from the output of terraform plan
and terraform apply
.
output "property_id" {
value = akamai_property.my_property.id
description = "The ID of my property"
sensitive = true
}
Exercise
New File
Create a terraform file called outputs.tf
Configure
Create outputs with the IDs for all 3 data sources created in the Exercises section in module 4. Data Sources
Plan
Run terraform plan
. What's different in Terraforms output in the terminal?
Commit
Commit your changes and push them to GitHub.