Interview Prep/Terraform/Variables, Locals, Outputs and Types

How do you define an output and what is it for?

BeginnerConceptVariables, Locals, Outputs and Types
Answer

An output block exposes a value. In the root module it prints after apply and can be read by terraform output; in a child module it is how the caller gets values.

output "alb_dns" {
  value       = aws_lb.main.dns_name
  description = "Public DNS of the ALB"
}
All Terraform questions Roadmap: Terraform

More on Variables, Locals, Outputs and Types