0
0
Terraformcloud~20 mins

Why variables make configurations reusable in Terraform - Challenge Your Understanding

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

Which statement best explains why variables make Terraform configurations reusable?

AVariables automatically create new resources without any input from the user.
BVariables store the output of Terraform commands for later use.
CVariables prevent any changes to the configuration once it is deployed.
DVariables allow you to change values without editing the main configuration, so the same code can deploy different resources.
Attempts:
2 left
💡 Hint

Think about how you can use the same recipe but change ingredients easily.

Architecture
intermediate
2:00remaining
How do variables improve Terraform module reuse?

You have a Terraform module that creates a virtual machine. How do variables help you reuse this module for different projects?

ABy locking the module to a single fixed configuration.
BBy forcing you to copy and edit the module code for each project.
CBy allowing you to pass different VM names, sizes, and networks to the module without changing its code.
DBy automatically detecting the best VM size for each project.
Attempts:
2 left
💡 Hint

Think about how you can use the same tool but adjust settings for each use.

Configuration
advanced
2:00remaining
What is the output of this Terraform variable usage?

Given this Terraform snippet, what will be the value of resource_name after applying?

Terraform
variable "env" {
  default = "prod"
}

variable "app" {
  default = "web"
}

output "resource_name" {
  value = "${var.app}-${var.env}-01"
}
A"web-prod-01"
B"prod-web-01"
C"web-01-prod"
D"01-web-prod"
Attempts:
2 left
💡 Hint

Look at how the variables are combined in the output value.

security
advanced
2:00remaining
Why should sensitive variables be used in Terraform?

Which reason best explains why marking variables as sensitive improves security in Terraform?

ASensitive variables hide their values in logs and output to prevent accidental exposure of secrets.
BSensitive variables encrypt the values automatically in the cloud provider.
CSensitive variables prevent Terraform from using the values in resource creation.
DSensitive variables make the configuration run faster.
Attempts:
2 left
💡 Hint

Think about how you keep passwords hidden when sharing information.

service_behavior
expert
2:00remaining
What happens if a required variable is not provided in Terraform?

Consider a Terraform configuration with a variable declared without a default value. What will Terraform do if you run terraform apply without providing this variable?

ATerraform will fail with a syntax error before applying.
BTerraform will prompt you to enter a value for the variable before proceeding.
CTerraform will skip creating resources that depend on the variable.
DTerraform will use an empty string as the variable value automatically.
Attempts:
2 left
💡 Hint

Think about how Terraform handles missing required inputs interactively.