nerdexam
HashiCorpHashiCorp

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.

Read, generate, and modify configuration

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 count argument creates multiple instances of an entire resource block, not multiple nested blocks within a single resource instance.
  • D. Collection functions like for_each or map help manipulate data structures, but the dynamic block 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

#Dynamic blocks#Nested blocks#Variables#Configuration language

Community Discussion

No community discussion yet for this question.

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