nerdexam
HashiCorpHashiCorp

TA-002-P · Question #408

TA-002-P Question #408: Real Exam Question with Answer & Explanation

The correct answer is A: aws_instance.example.ebs_block_device.[*].volume_id. {"question_number": 7, "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_insta

Read, generate, and modify configuration

Question

How would you reference the Volume IDs associated with the ebs_block_device blocks in this configuration?

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

Explanation

{"question_number": 7, "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.", "generated_by": "claude-sonnet", "llm_judge_score": 4}

Topics

#Terraform HCL Syntax#Referencing Attributes#Splat Operator#Nested Blocks

Community Discussion

No community discussion yet for this question.

Full TA-002-P PracticeBrowse All TA-002-P Questions