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.
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)- B5% (1)
- D95% (21)
Why each option
The 'dynamic' block in Terraform is the construct used to programmatically generate repeated nested configuration blocks.
'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.
'repeated' is not a valid Terraform language construct or block type.
'nesting' is not a valid Terraform block type; it is an informal term describing block hierarchy, not a language keyword.
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
Community Discussion
No community discussion yet for this question.