Exam Terraform-Associate-004 Topic 5 Question 110 Discussion

Actual exam question for HashiCorp's Terraform-Associate-004 exam
Question #: 110
Topic #: 5
You are creating a reusable Terraform configuration and want to include an optional billing_dept tag so your Finance team can track team-specific spending on resources. Which of the following billing_dept variable declarations will achieve this?

Suggested Answer: A Vote an answer

Detailed Explanation:
* Rationale for Correct Answer: In Terraform, an input variable is "optional" if it has a default value .
Setting default = " " allows callers to omit the variable entirely, while still producing a known value (empty string) that you can conditionally include/exclude when building tags. This directly supports reusable module/config design: sensible defaults make variables optional.
* Analysis of Incorrect Options (Distractors):
* B: Incorrect. optional = true is not valid syntax for variable blocks in Terraform.
* C: Incorrect. optional(string) is used for optional attributes in object type constraints , not as a top-level variable type declaration in this way for making a variable optional.
* D: Incorrect. type = default is not valid Terraform syntax.
* Key Concept: A variable becomes optional by providing a default value .
Reference: Read, Generate, and Modify Configurations - input variable declarations, defaults, and module reusability patterns.

by Ada at Aug 16, 2026, 06:40 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10