Question 380
A Terraform associate evaluates: A configuration needs to address one managed instance by a stable string key. Select TWO complementary responses: the appropriate action AND direct evidence it worked.
Explanation
Correct Answers
The case says: A configuration needs to address one managed instance by a stable string key. The directly relevant Terraform response is: Use for_each keyed by stable resource identifiers for collections whose entries change independently and count for genuinely index-oriented repetition. This addresses the related failure mode: Removing a middle entry from a count-indexed collection can shift addresses and provoke unintended replacements. Validate the result by checking: The plan adds or removes the intended keyed resource without renumbering unrelated instances. The selection matches this objective, rather than a different Terraform administration task.
The observed situation is: A configuration needs to address one managed instance by a stable string key. The acceptance evidence is: The plan adds or removes the intended keyed resource without renumbering unrelated instances. It verifies the corrective approach (Use for_each keyed by stable resource identifiers for collections whose entries change independently and count for genuinely index-oriented repetition.) and controls the risk: Removing a middle entry from a count-indexed collection can shift addresses and provoke unintended replacements. Checking an unrelated Terraform setting would not prove the stated requirement was met.
Incorrect Answers
Use Terraform expressions and built-in functions such as merge, lookup, length and format to compute values reproducibly from configuration inputs. This belongs to Terraform expressions and built-in functions (official objective 4e). Its separate risk is that manually duplicating derived labels and tags across resources invites inconsistency and errors. The question instead tests count versus for_each stable addressing; that other safeguard alone does not verify it.
A replacement may fail if a globally unique name prevents a second object from existing simultaneously. This is relevant to Lifecycle create_before_destroy (official objective 4f). Its distinct failure risk is that a replacement may fail if a globally unique name prevents a second object from existing simultaneously. The present question tests count versus for_each stable addressing, which this measure alone does not establish.
A plan shows the intended input values for the selected environment and variable validation accepts them. This does not provide the required count versus for_each stable addressing action-and-evidence pair.