Query Data with Outputs
Last updated
Was this helpful?
Last updated
Was this helpful?
In the previous tutorial, you used an input variable to parameterize your Terraform configuration. In this tutorial, you will use output values to present useful information to the Terraform user.
If you have not yet completed the tutorial, do so before following this one.
Create a file called outputs.tf
in your learn-terraform-aws-instance
directory.
Add the configuration below to outputs.tf
to define outputs for your EC2 instance's ID and IP address.
You must apply this configuration before you can use these output values. Apply your configuration now. Respond to the confirmation prompt with yes
.
Terraform prints output values to the screen when you apply your configuration. Query the outputs with the terraform output
command.
You can use Terraform outputs to connect your Terraform projects with other parts of your infrastructure, or with other Terraform projects. To learn more, follow our in-depth tutorial, .