0
0
Terraformcloud~5 mins

Output declaration syntax in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of an output declaration in Terraform?
An output declaration in Terraform shows important information after applying the configuration, like IP addresses or resource IDs, so you can use or see them easily.
Click to reveal answer
beginner
Basic syntax of a Terraform output declaration?
Use the keyword output followed by a name without quotes, then a block with value = and the expression to output.<br>Example:<br>
output "example" {
  value = aws_instance.myserver.id
}
Click to reveal answer
intermediate
Can Terraform outputs have descriptions? Why use them?
Yes, outputs can have a description field to explain what the output means. This helps others understand the purpose of the output when reading the Terraform plan or state.
Click to reveal answer
intermediate
How do you mark an output as sensitive in Terraform?
Add sensitive = true inside the output block to hide the output value from normal display, protecting secrets or private data.
Click to reveal answer
beginner
What happens if you omit the value in an output declaration?
Terraform requires the value field in an output block. Omitting it causes an error because Terraform doesn't know what to show as output.
Click to reveal answer
Which keyword starts an output declaration in Terraform?
Aresource
Boutput
Cvariable
Dprovider
How do you hide sensitive output values in Terraform?
ASet <code>private = true</code>
BUse <code>hidden = true</code>
CAdd <code>sensitive = true</code> inside the output block
DOutputs cannot be hidden
What must every Terraform output block include?
AA <code>value</code> field
BA <code>description</code> field
CA <code>type</code> field
DA <code>depends_on</code> field
What is the correct way to reference an AWS instance ID in an output?
Aaws_instance.myserver.id
Baws_instance.id.myserver
Cmyserver.aws_instance.id
Did.aws_instance.myserver
Why add a description to an output?
ATo change the output type
BTo make the output required
CTo hide the output
DTo explain what the output means
Write the syntax for a Terraform output that shows the public IP of a server and includes a description.
Start with output, give it a name, add value and description inside curly braces.
You got /5 concepts.
    Explain how to protect sensitive information in Terraform outputs and why it is important.
    Think about what happens if secret data is shown openly.
    You got /4 concepts.