Course contentsShow
← Cloud and Infrastructure
Lesson 764 of 2,98914. Terraform FundamentalsFree lesson

Introduction to Outputs

Learn how output values expose information from your Terraform configuration.

Introduction to Outputs

What you'll learn: You'll discover how Terraform outputs let you extract and display specific values from your infrastructure after deployment.

What Are Outputs?

Think of outputs like the "return values" of your infrastructure code. When Terraform creates resources—like a virtual machine, database, or load balancer—those resources generate various attributes (IP addresses, URLs, identifiers). Output values allow you to explicitly expose the information you care about, making it visible after terraform apply completes.

Without outputs, you'd have to dig through your cloud provider's console or state file to find critical details. Outputs surface them automatically.

Why Use Outputs?

Outputs serve several purposes:

  • Display important information after provisioning (like a server's public IP or a database endpoint)
  • Pass data between Terraform configurations when using modules or separate workspaces
  • Feed values to other tools in your automation pipeline (CI/CD systems, scripts, monitoring tools)
  • Document your infrastructure's key details for team members

Basic Concept

You define outputs in your configuration files using an output block. Each output has a name and references a value—typically an attribute from a resource or data source you've already defined. When Terraform finishes applying changes, it prints these outputs to the terminal and stores them in the state file.

Think of it like a restaurant kitchen: your infrastructure code is the cooking process, and outputs are the finished dishes presented to the customer. You're selecting exactly what information to serve up from all the work happening behind the scenes.

Key Takeaway: Outputs expose specific values from your Terraform-managed resources, making critical infrastructure details easily accessible without manual lookup.