TERRAFORM-ASSOCIATE-004 · Question #11
How would you reference the volume IDs associated with the ebs_block_device blocks in this configuration?
The correct answer is D. aws_instance.example-ebs_block_device.*.volume_id. To reference attributes across multiple ebs_block_device blocks, Terraform uses the legacy splat expression (.). Option A uses invalid bracket/comma syntax. Option B has a typo (aws_lnstance with a lowercase L) and an extra dot before the brackets (.[]). Option C incorrectly uses
Question
Options
- Aaws_instance.example.ebs_block_device[sda2,sda3).volume_id
- Baws_lnstance.example.ebs_block_device.[*].volume_id
- Caws_lnstance.example.ebs_block_device.volume_ids
- Daws_instance.example-ebs_block_device.*.volume_id
How the community answered
(64 responses)- A6% (4)
- B3% (2)
- C11% (7)
- D80% (51)
Explanation
To reference attributes across multiple ebs_block_device blocks, Terraform uses the legacy splat expression (.*). Option A uses invalid bracket/comma syntax. Option B has a typo (aws_lnstance with a lowercase L) and an extra dot before the brackets (.[*]). Option C incorrectly uses a plural attribute name volume_ids, which doesn't exist. Option D - aws_instance.example.ebs_block_device.*.volume_id - uses the correct legacy splat operator to iterate over all ebs_block_device blocks and return a list of their volume_id attributes. (Note: the hyphen in choice D appears to be a typographical artifact in the question; the intended syntax is with a dot separator.)
Topics
Community Discussion
No community discussion yet for this question.