TA-002-P · Question #330
TA-002-P Question #330: Real Exam Question with Answer & Explanation
The correct answer is B: Dynamic blocks. Dynamic blocks allow you to generate multiple nested configuration blocks within a resource by iterating over a complex variable, which is ideal for defining multiple data disks for a virtual machine.
Question
You want to define multiple data disks as nested blocks inside the resource block for a virtual machine. What Terraform feature would help you define the blocks using the values in a variable?
Options
- ALocal values
- BDynamic blocks
- CCount arguments
- DCollection functions
Explanation
Dynamic blocks allow you to generate multiple nested configuration blocks within a resource by iterating over a complex variable, which is ideal for defining multiple data disks for a virtual machine.
Common mistakes.
- A. Local values assign names to expressions for reuse but do not directly facilitate the dynamic creation of multiple nested blocks within a resource.
- C. The
countargument creates multiple instances of an entire resource block, not multiple nested blocks within a single resource instance. - D. Collection functions like
for_eachormaphelp manipulate data structures, but thedynamicblock is the specific language feature used to construct nested blocks based on those collections.
Concept tested. Terraform dynamic blocks
Reference. https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks
Topics
Community Discussion
No community discussion yet for this question.