0
0
Terraformcloud~30 mins

Output values after apply in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Output values after apply
📖 Scenario: You are setting up a simple cloud infrastructure using Terraform. After creating resources, you want to see important information like the resource ID and IP address once the deployment is done.
🎯 Goal: Create a Terraform configuration that defines a resource and outputs its ID and IP address after applying the configuration.
📋 What You'll Learn
Define a resource with a fixed name
Create output values for resource ID and IP address
Use exact variable and resource names as specified
Outputs must be visible after terraform apply
💡 Why This Matters
🌍 Real World
Cloud engineers often need to see resource details like IDs and IPs after deployment to connect or configure other services.
💼 Career
Knowing how to create and use outputs in Terraform is essential for infrastructure automation and collaboration in cloud roles.
Progress0 / 4 steps
1
Define a simple resource
Create a resource called aws_instance with the name example and set the ami to "ami-12345678" and instance_type to "t2.micro".
Terraform
Need a hint?

Use the resource block with type aws_instance and name example. Set the ami and instance_type exactly as shown.

2
Add output for instance ID
Create an output called instance_id that outputs the id attribute of the aws_instance.example resource.
Terraform
Need a hint?

Use an output block with the name instance_id. Set its value to aws_instance.example.id.

3
Add output for public IP
Create an output called public_ip that outputs the public_ip attribute of the aws_instance.example resource.
Terraform
Need a hint?

Use an output block named public_ip and set its value to aws_instance.example.public_ip.

4
Add description to outputs
Add a description attribute to both instance_id and public_ip outputs. Use "The ID of the instance" for instance_id and "The public IP address of the instance" for public_ip.
Terraform
Need a hint?

Add the description attribute inside each output block with the exact text given.