Rationale for Correct Answer: To make a variable optional, you define a type that allows omission. Using optional(string) indicates the input may be unset (commonly used when the variable is part of an object type, or when you want to explicitly model optionality). This supports reusable configs where the tag is included only when provided.
Analysis of Incorrect Options (Distractors):
A: Invalid syntax—type = default is not a valid type declaration.
B: Invalid syntax—default must have a value.
D: Invalid—there is no optional = true argument for variable blocks.
Key Concept: Input variable type constraints and optional inputs.
[Reference: Terraform Objectives — Read, Generate, and Modify Configurations (variables, types, and reusable configuration patterns)., , , , ]
Submit