0
0
Terraformcloud~30 mins

Outputs as documentation in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Outputs as documentation
📖 Scenario: You are setting up a simple cloud infrastructure using Terraform. You want to make sure that after deployment, important information about your resources is easy to find and understand. Outputs in Terraform help you document and share key details about your infrastructure.
🎯 Goal: Create Terraform outputs that clearly document the important attributes of your deployed resources, so anyone can quickly see the essential information after deployment.
📋 What You'll Learn
Create a Terraform variable for the instance name
Define a resource block for an AWS EC2 instance with the given name
Add outputs to show the instance ID and public IP
Use outputs to document the instance name and instance type
💡 Why This Matters
🌍 Real World
Outputs in Terraform help teams quickly find important information about deployed resources without searching through code or cloud consoles.
💼 Career
Knowing how to use outputs for documentation is essential for cloud engineers to communicate infrastructure details clearly and maintain infrastructure as code.
Progress0 / 4 steps
1
Create a Terraform variable for the instance name
Write a Terraform variable block named instance_name with type string and default value "my-instance".
Terraform
Need a hint?

Use the variable block with type and default attributes.

2
Define an AWS EC2 instance resource using the variable
Write a Terraform resource block named aws_instance with resource name example. Set the ami to "ami-12345678", instance_type to "t2.micro", and tags with Name set to the variable instance_name.
Terraform
Need a hint?

Use resource "aws_instance" "example" and set the attributes exactly as specified.

3
Add outputs for instance ID and public IP
Write two Terraform output blocks named instance_id and instance_public_ip. Set their value to aws_instance.example.id and aws_instance.example.public_ip respectively.
Terraform
Need a hint?

Use output blocks with the exact names and values.

4
Add outputs to document instance name and instance type
Write two Terraform output blocks named instance_name_output and instance_type_output. Set their value to var.instance_name and aws_instance.example.instance_type respectively. Add description attributes explaining these outputs as documentation.
Terraform
Need a hint?

Add description attributes to outputs to explain their purpose.