0
0
Terraformcloud~5 mins

Sensitive variables in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a sensitive variable in Terraform?
A sensitive variable is a variable that holds secret or private information, like passwords or keys, which Terraform hides from output to keep it safe.
Click to reveal answer
beginner
How do you declare a sensitive variable in Terraform?
You declare a variable with the attribute sensitive = true inside the variable block to mark it as sensitive.
Click to reveal answer
beginner
Why should sensitive variables not be printed in Terraform outputs?
Printing sensitive variables can expose secrets in logs or terminal, risking security. Terraform hides them to protect sensitive data.
Click to reveal answer
intermediate
Can sensitive variables be used in Terraform resource configurations?
Yes, sensitive variables can be used normally in resource configurations, but Terraform will avoid showing their values in plan or apply outputs.
Click to reveal answer
intermediate
What happens if you try to output a sensitive variable without marking the output as sensitive?
Terraform will warn you and hide the value in the output to prevent accidental exposure of secrets.
Click to reveal answer
How do you mark a variable as sensitive in Terraform?
APrefix the variable name with 'secret_'
BUse <code>private = true</code> in the variable block
CAdd <code>sensitive = true</code> in the variable block
DSet <code>hidden = true</code> in the variable block
What does Terraform do when you output a sensitive variable without marking the output as sensitive?
AShows the value normally
BThrows an error and stops
CDeletes the variable
DHides the value and shows a warning
Why should sensitive variables be used in Terraform?
ATo keep secret information safe
BTo store large data files
CTo speed up Terraform runs
DTo make variables public
Can you use sensitive variables inside resource definitions?
AYes, but values are hidden in outputs
BNo, Terraform blocks it
COnly if you disable sensitivity
DOnly for string variables
What is a best practice when handling sensitive variables in Terraform?
AStore them in plain text files
BMark them as sensitive and avoid printing
CShare them in team chats
DPrint them in logs for debugging
Explain how to declare and use sensitive variables in Terraform and why it is important.
Think about how you keep passwords safe in real life.
You got /4 concepts.
    Describe what happens when you output a sensitive variable without marking the output as sensitive in Terraform.
    Terraform acts like a privacy guard for secrets.
    You got /3 concepts.