0
0
Terraformcloud~10 mins

Sensitive variable handling in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a sensitive variable in Terraform.

Terraform
variable "db_password" {
  type      = string
  [1] = true
}
Drag options to blanks, or click blank then click option'
Adefault
Bsensitive
Cdescription
Dnullable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' instead of 'sensitive' hides the value incorrectly.
Confusing 'description' with sensitivity setting.
2fill in blank
medium

Complete the code to output a sensitive variable without revealing its value.

Terraform
output "db_password" {
  value     = var.db_password
  [1] = true
}
Drag options to blanks, or click blank then click option'
Adescription
Bexported
Csensitive
Dhidden
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'hidden' which is not a valid Terraform output property.
Omitting the sensitive property, which reveals the value.
3fill in blank
hard

Fix the error in the variable declaration to properly mark it as sensitive.

Terraform
variable "api_key" {
  type      = string
  sensitive = [1]
}
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cyes
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using string values like "true" instead of boolean true.
Using numeric or other string values.
4fill in blank
hard

Fill both blanks to create a sensitive variable with a default value.

Terraform
variable "admin_password" {
  type      = string
  [1] = true
  [2] = "defaultPass123"
}
Drag options to blanks, or click blank then click option'
Asensitive
Bdescription
Cdefault
Dnullable
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up 'description' and 'default'.
Not marking the variable as sensitive.
5fill in blank
hard

Fill all three blanks to output a sensitive variable with a description and hide its value.

Terraform
output "secret_token" {
  value       = var.secret_token
  [1] = true
  [2] = "The secret token for API access"
  [3] = true
}
Drag options to blanks, or click blank then click option'
Asensitive
Bdescription
Dexported
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'exported' which is not a valid property.
Omitting the sensitive property, exposing the secret.