Query Data with Outputs
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 Define Input Variables tutorial, do so before following this one.
Output EC2 instance configuration
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.
Inspect output values
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, Output Data from Terraform.
Last updated