nerdexam
HashiCorp

TA-002-P · Question #90

What type of block is used to construct a collection of nested configuration blocks?

The correct answer is D. dynamic. The 'dynamic' block in Terraform is the construct used to programmatically generate repeated nested configuration blocks.

Read, generate, and modify configuration

Question

What type of block is used to construct a collection of nested configuration blocks?

Options

  • Afor_each
  • Brepeated
  • Cnesting
  • Ddynamic

How the community answered

(22 responses)
  • B
    5% (1)
  • D
    95% (21)

Why each option

The 'dynamic' block in Terraform is the construct used to programmatically generate repeated nested configuration blocks.

Afor_each

'for_each' is a meta-argument that creates multiple top-level resource instances, not a block type for constructing nested blocks within a single resource.

Brepeated

'repeated' is not a valid Terraform language construct or block type.

Cnesting

'nesting' is not a valid Terraform block type; it is an informal term describing block hierarchy, not a language keyword.

DdynamicCorrect

A 'dynamic' block iterates over a collection and generates multiple nested blocks within a resource or data block, using a 'content' sub-block to define each iteration's attributes. It is the only block type in Terraform specifically designed to produce repeated nested configuration blocks at plan time. This replaces the need to statically write duplicate nested blocks for variable-length collections.

Concept tested: Terraform dynamic blocks for nested configuration

Source: https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks

Topics

#Terraform HCL#Dynamic Blocks#Nested Configuration#Configuration Blocks

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice