TA-002-P · Question #318
Which statements best describes what the local variable assignment is doing in the following code snippet:
The correct answer is D. Create a list of route table names eliminating duplicates. The local variable assignment is creating a list of route table names and using a function to remove any duplicate entries, resulting in a unique list.
Question
Which statements best describes what the local variable assignment is doing in the following code snippet:
Options
- ACreate a distinct list of route table name objects
- BCreate a map of route table names to subnet names
- CCreate a map of route table names from a list of subnet names
- DCreate a list of route table names eliminating duplicates
How the community answered
(32 responses)- A3% (1)
- B6% (2)
- C3% (1)
- D88% (28)
Why each option
The local variable assignment is creating a list of route table names and using a function to remove any duplicate entries, resulting in a unique list.
While it creates a distinct list of names, "objects" implies complex structures, whereas it's typically just strings, and the most accurate description focuses on eliminating duplicates from a list.
The operation describes creating a list of names, not a map, and there's no explicit mapping to subnet names.
The operation describes creating a list of names, not a map, and the flow is not "from a list of subnet names" to "route table names" in a mapping context.
Assuming the snippet uses a function like `distinct()` or similar on a list of route table names, the operation specifically aims to process an input list and return a new list containing only unique elements. This effectively eliminates any duplicate route table names from the original collection.
Concept tested: Terraform local variables and list manipulation
Source: https://developer.hashicorp.com/terraform/language/functions/distinct
Topics
Community Discussion
No community discussion yet for this question.