Returning data with outputs
We've already talked very briefly about outputs in previous chapters. By this moment, you should already know what they are. However, let's recap their usage anyways.
Outputs allow returning data from the Terraform template after it was applied using the terraform output
command. For example, to return the IP address of some EC2 instance, we could define an output as follows:
output "public_ip" { value = "${aws_instance.web-server.public_ip}" }
That allows us to easily pass this data to other scripts and tools. For example, with this approach, we could run tests against our servers. Enter Inspec.