0
0
Terraformcloud~10 mins

Sensitive variables 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' to hide the value.
Confusing 'description' with sensitivity.
2fill in blank
medium

Complete the code to assign a sensitive variable value from environment variables.

Terraform
variable "api_key" {
  type      = string
  sensitive = true
}

provider "example" {
  key = var.[1]
}
Drag options to blanks, or click blank then click option'
Aapi_key
BApiKey
CAPI_KEY
Dapikey
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase or camelCase variable names incorrectly.
Referencing environment variable names directly instead of Terraform variable.
3fill in blank
hard

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

Terraform
variable "admin_password" {
  type      = string
  sensitive = [1]
}
Drag options to blanks, or click blank then click option'
A"true"
B1
CTrue
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around boolean values.
Using uppercase True instead of lowercase true.
4fill in blank
hard

Fill both blanks to declare a sensitive variable with a description.

Terraform
variable "token" {
  [1] = string
  [2] = true
  description = "API token for service"
}
Drag options to blanks, or click blank then click option'
Atype
Bdefault
Csensitive
Dnullable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' instead of 'type'.
Forgetting to mark sensitive as true.
5fill in blank
hard

Fill all three blanks to create a sensitive variable with a default value and description.

Terraform
variable "secret_key" {
  [1] = string
  [2] = true
  [3] = "Default secret key"
}
Drag options to blanks, or click blank then click option'
Atype
Bsensitive
Cdefault
Ddescription
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'description' with 'default'.
Omitting the sensitive flag.