You can use every part of a resource as an output. This is useful to get the value of a resource and use it in another resource.
-
Create a new file
outputs.tf
and add the following content:
output "private_ip" {
value = aws_instance.example.private_ip
}
-
Run
terraform apply
andterraform output
to see the value of the output
It is also possible to get only the value of the output by running terraform output private_ip
Next step: Data sources