Returning data with outputs
We've already talked very briefly about outputs in previous chapters. By this time, you should already know what they are. However, let's recap their usage anyway.
Outputs allow the returning of data from the Terraform template after it was applied using the terraform output
command. For example, to return the IP address of an 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.