HashiCorp
TERRAFORM-ASSOCIATE-003 · Question #22
You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.
The correct answer is B. [ for o in var.list : o.Id ] C. var.list[*].id. These are two ways to produce a list of the IDs from a list of objects that have an attribute id, using either a for expression or a splat expression syntax.
Read, generate, and modify configuration
Question
You have declared a variable called var.list which is a list of objects that all have an attribute id . Which options will produce a list of the IDs? Choose two correct answers.
Options
- A[ var.list [ * ] , id ]
- B[ for o in var.list : o.Id ]
- Cvar.list[*].id
- D{ for o in var.llst : o => o.id }
How the community answered
(59 responses)- A10% (6)
- B73% (43)
- D17% (10)
Explanation
These are two ways to produce a list of the IDs from a list of objects that have an attribute id, using either a for expression or a splat expression syntax.
Topics
#splat expression#for expression#list comprehension#complex types
Community Discussion
No community discussion yet for this question.