TA-002-P · Question #408
How would you reference the Volume IDs associated with the ebs_block_device blocks in this configuration?
The correct answer is A. aws_instance.example.ebs_block_device.[*].volume_id. Because ebs_block_device is a block that can appear multiple times in a single aws_instance resource, it forms a set of objects. To retrieve an attribute across all instances of a repeated block, you use a splat expression with []…
Question
How would you reference the Volume IDs associated with the ebs_block_device blocks in this configuration?
Exhibit
Options
- Aaws_instance.example.ebs_block_device.[*].volume_id
- Baws_instance.example.ebs_block_device.volume_id
- Caws_instance.example.ebs_block_device[sda2,sda3].volume_id
- Daws_instance.example.ebs_block_device.*.volume_id
How the community answered
(28 responses)- A79% (22)
- B4% (1)
- C14% (4)
- D4% (1)
Explanation
Because ebs_block_device is a block that can appear multiple times in a single aws_instance resource, it forms a set of objects. To retrieve an attribute across all instances of a repeated block, you use a splat expression with [*]: aws_instance.example.ebs_block_device.[*].volume_id. This returns a list of all volume IDs from all ebs_block_device blocks. The legacy splat syntax .* also works but [*] is the modern, preferred form. Options B and C are syntactically invalid for this use case. Answer A is correct.
Topics
Community Discussion
No community discussion yet for this question.
