0
0
Terraformcloud~20 mins

Sensitive variables in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sensitive Variables Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Sensitive Variables in Terraform

What is the primary purpose of marking a variable as sensitive = true in Terraform?

ATo prevent the variable's value from being displayed in Terraform plan and apply outputs.
BTo encrypt the variable's value in the state file automatically.
CTo make the variable read-only and prevent changes after initial assignment.
DTo allow the variable to be used only in provider configurations.
Attempts:
2 left
💡 Hint

Think about what happens when Terraform shows outputs during execution.

Configuration
intermediate
2:00remaining
Terraform Sensitive Variable Declaration

Which Terraform variable declaration correctly marks the variable db_password as sensitive?

A
variable "db_password" {
  type = string
  secret = true
}
B
variable "db_password" {
  type = string
  sensitive = true
}
C
variable "db_password" {
  type = string
  hidden = true
}
D
variable "db_password" {
  type = string
  secure = true
}
Attempts:
2 left
💡 Hint

Check the exact attribute name Terraform uses for marking variables as sensitive.

service_behavior
advanced
2:00remaining
Effect of Sensitive Variables on Terraform Outputs

Given this Terraform output block:

output "db_password" {
  value     = var.db_password
  sensitive = true
}

What will happen when you run terraform apply?

AThe output value will not be shown in the CLI output after apply.
BTerraform will throw an error because outputs cannot be sensitive.
CTerraform will display the output value but mask it with asterisks.
DTerraform will encrypt the output value in the state file automatically.
Attempts:
2 left
💡 Hint

Consider how Terraform treats outputs marked as sensitive during apply.

security
advanced
2:00remaining
Security Implications of Sensitive Variables in Terraform State

Which statement about sensitive variables and Terraform state files is true?

ATerraform automatically removes sensitive variables from the state file after apply.
BSensitive variables are encrypted in the Terraform state file by default.
CSensitive variables are stored in plain text in the Terraform state file unless additional encryption is configured.
DSensitive variables cannot be stored in the state file at all.
Attempts:
2 left
💡 Hint

Think about what Terraform does with sensitive data internally.

Architecture
expert
3:00remaining
Best Practice for Managing Sensitive Variables in Terraform Architecture

You want to manage sensitive variables like API keys securely in Terraform for a team project. Which approach is the best practice?

AStore sensitive variables in Terraform variable files checked into version control with <code>sensitive = true</code> set.
BHardcode sensitive variables directly in Terraform configuration files for simplicity.
CDisable sensitive marking and rely on team members to not share outputs or logs.
DUse environment variables or a secrets manager and pass sensitive variables at runtime without storing them in code or state files.
Attempts:
2 left
💡 Hint

Consider how to avoid exposing secrets in code and state files.