0
0
Terraformcloud~20 mins

Output declaration syntax in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Output Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Configuration
intermediate
2:00remaining
Identify the correct output declaration syntax
Which Terraform output declaration will correctly output the value of the variable instance_id?
Aoutput "instance_id" = var.instance_id
Boutput "instance_id" { value = var.instance_id }
Coutput instance_id = var.instance_id
Doutput { instance_id = var.instance_id }
Attempts:
2 left
💡 Hint
Terraform output blocks require a name in quotes and a value attribute inside curly braces.
service_behavior
intermediate
2:00remaining
What is the output value type?
Given the following Terraform output declaration, what is the type of the output value?
Terraform
output "server_ips" {
  value = ["10.0.0.1", "10.0.0.2"]
}
AA list of strings
BA map of strings
CA single string
DA boolean
Attempts:
2 left
💡 Hint
Look at the square brackets and the values inside.
Architecture
advanced
2:00remaining
Which output declaration correctly exports a nested attribute?
You have a resource aws_instance.web with an attribute public_ip. Which output declaration correctly exports this attribute?
Aoutput "web_ip" { value = aws_instance.web.public_ip }
Boutput "web_ip" { value = aws_instance["web"].public_ip }
Coutput "web_ip" { value = aws_instance.web["public_ip"] }
Doutput "web_ip" { value = aws_instance.web.public_ip_address }
Attempts:
2 left
💡 Hint
Use dot notation to access resource attributes.
security
advanced
2:00remaining
Which output declaration exposes sensitive data correctly?
You want to output a database password stored in var.db_password but keep it hidden in Terraform output. Which declaration is correct?
Aoutput "db_password" { value = var.db_password hidden = true }
Boutput "db_password" { value = var.db_password sensitive = false }
Coutput "db_password" { value = var.db_password }
Doutput "db_password" { value = var.db_password sensitive = true }
Attempts:
2 left
💡 Hint
Terraform supports a sensitive flag in output blocks.
Best Practice
expert
2:00remaining
What is the effect of missing the output block's value attribute?
Consider this Terraform output declaration:
output "region" {}
What happens when you run terraform apply?
ATerraform outputs null for region
BTerraform outputs an empty string for region
CTerraform raises a validation error about missing value attribute
DTerraform ignores the output block silently
Attempts:
2 left
💡 Hint
Output blocks require a value attribute to be valid.