← Lessons/Variables, Outputs & Data Sources
← Variables, Outputs & Data Sources

Surface values with outputs

Learn

Outputs: return values

output "private_ip" {
  value = demo_server.web.private_ip
}

Outputs surface values after apply — most usefully the computed ones you can't know ahead of time, like a server's private_ip or id. They print at the end of every apply:

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

private_ip = "10.0.66.189"
server_name = "web"

They're how one config hands values to a human, a script (terraform output -raw private_ip), or another module. An output can be any expression: a variable, a resource attribute, or something computed from several.

Switch to apply to create the server, and add two outputs: output "server_name" with value = var.server_name, and output "private_ip" with value = demo_server.web.private_ip. After apply, the Outputs section shows your name and the server's computed IP — a value you couldn't know until it existed.

Loading...

State Inspector

State

Terraform's memory

empty — nothing here yet

Real Infrastructure

the actual world

empty — nothing here yet