Skip to content

Quiz — Variables, Expressions & Guards

Quiz results are saved to your browser's local storage and will persist between sessions.

Variable precedence, and the count/for_each guard patterns that decide whether a resource exists at all. The last three questions are all the same underlying trap: a guard protects only what it directly wraps.

6 questions. Back to all topics

#

You edit a variable's default value in variables.tf, but terraform.tfvars already sets that same variable. Which value does Terraform actually use?

#

A repo has local.static_envs = ["dev", "qa"] and separately a var.static_env boolean that controls review-environment behavior. Does Terraform automatically ensure these two stay consistent (e.g. that running on the 'dev' workspace automatically sets static_env = true)?

#

One local value is wrapped in try(..., "") with a null-check before use (feeding a graceful mock-data fallback). A different local value in the same repo calls jsondecode directly with no guard, and fails loudly if the upstream data is missing. Is the unguarded one necessarily worse code?

#

A local value filters out entries whose upstream dependency doesn't exist yet, e.g. { for k, v in x : k => v if condition }. Two other resources elsewhere in the same repo still do for_each = toset(local.full_unfiltered_list) and then index into the now-filtered map directly. What happens?

#

A resource has count = local.some_condition ? 1 : 0. When the condition is false, what actually happens to that resource?

#

A module block uses for_each over a map filtered down to only enabled entries: for_each = { for k, v in x : k => v if v.enabled }. If both entries in the map are disabled, what does for_each-over-modules actually do?

Quiz Progress

0 / 0 questions answered (0%)

0 correct