0
0
Terraformcloud~15 mins

Sensitive output values in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Sensitive output values
📖 Scenario: You are managing cloud infrastructure using Terraform. Some outputs contain sensitive information like passwords or API keys. You want to keep these values hidden when Terraform shows outputs after applying changes.
🎯 Goal: Create a Terraform configuration that defines an output with a sensitive value. Mark the output as sensitive so Terraform does not display it openly.
📋 What You'll Learn
Create a Terraform output named db_password with the value "supersecret123"
Mark the db_password output as sensitive using the sensitive = true attribute
💡 Why This Matters
🌍 Real World
Cloud engineers often manage secrets like passwords or API keys. Marking outputs as sensitive helps keep these secrets safe from accidental exposure.
💼 Career
Knowing how to handle sensitive data in Terraform is essential for secure infrastructure management and compliance.
Progress0 / 4 steps
1
Create a basic Terraform output
Write a Terraform output block named db_password with the value "supersecret123".
Terraform
Need a hint?

Use the output block with a value attribute.

2
Add the sensitive attribute
Add the attribute sensitive = true inside the db_password output block to mark it as sensitive.
Terraform
Need a hint?

The sensitive attribute hides the output value from Terraform's normal output.

3
Add a second non-sensitive output
Create another Terraform output named db_username with the value "adminuser" without marking it sensitive.
Terraform
Need a hint?

Outputs without sensitive = true will show their values normally.

4
Complete the Terraform outputs configuration
Ensure the Terraform configuration includes both outputs: db_password marked sensitive and db_username not sensitive, exactly as before.
Terraform
Need a hint?

Both outputs should be present with correct attributes.