Question 610
At Thornvale Cloud Operations, an authorized infrastructure engineering team manages a Terraform 1.12 and HCP Terraform environment. The team encounters the following situation: a counted resource has several instances but an output returns only one hardcoded index. Choose the technically best Terraform Associate 004 practice response to this particular infrastructure case. What mechanism explains why the original approach fails?
Explanation
Correct Answer
A collection-valued resource has multiple instance results rather than one scalar attribute. That mechanism distinguishes splat expression multiple attributes in the Thornvale Cloud Operations case. The corresponding appropriate correction is: Use a full splat or for expression to collect every intended instance attribute. The measurable acceptance test is: The output includes an identifier for every created instance.
Incorrect Answers
This alternative is valid when direct indexing fails for missing map keys while lookup can provide a documented fallback. The facts here establish a different controlling reason: A collection-valued resource has multiple instance results rather than one scalar attribute.
“Explicit command-line variable assignments take precedence over defaults” reflects the mechanism: Explicit command-line variable assignments take precedence over defaults. The actual reported symptoms are better explained by: A collection-valued resource has multiple instance results rather than one scalar attribute.
This alternative is valid when state can record provider-computed attributes such as an endpoint name. The facts here establish a different controlling reason: A collection-valued resource has multiple instance results rather than one scalar attribute.