Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 90


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

Show Answer
Correct Answer: D

The correct type of block used to construct a collection of nested configuration blocks in Terraform is the dynamic block. Dynamic blocks allow you to generate nested blocks based on a given complex value, such as a list or map, and provide a way to repeat portions of configuration that are conditional or dependent on input data. The dynamic block uses the for_each argument to iterate over the specified collection and create nested blocks accordingly. This feature helps in creating more flexible and reusable configurations in Terraform.

Discussion

7 comments
Sign in to comment
bp339Option: D
Dec 4, 2022

Dynamic is true...

EltoothOption: D
Dec 29, 2022

D is correct answer : dynamic https://www.terraform.io/language/expressions/dynamic-blocks

eduvar4Option: D
Mar 27, 2023

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

alen995454
Jul 13, 2024

form page shared above: "A dynamic block acts much like a for expression, but produces nested blocks instead of a complex typed value. It iterates over a given complex value, and generates a nested block for each element of that complex value." "The for_each argument provides the complex value to iterate over." To me this says "D" is correct

Abhijeet2904Option: A
Aug 6, 2023

A. for_each In Terraform, you can use the "for_each" block to construct a collection of nested configuration blocks that are repeated based on an input list or map data structure. The "for_each" block allows you to define reusable code that can be applied to multiple resources, similar to a loop in a programming language. The block takes a data structure as an argument and creates one block of nested configuration for each element in the data structure, allowing you to manage multiple similar resources in a more streamlined way.

Nunyabiznes
Sep 24, 2023

The dynamic block in Terraform is used to construct nested configuration blocks dynamically based on a collection of values, such as a list or a map. This block type allows you to create multiple instances of the same resource or module, without having to duplicate the configuration code. The for_each argument is used with the dynamic block to specify the collection of values to iterate over. The content block inside the dynamic block is used to define the configuration for each iteration.

Power123
Sep 30, 2023

Dynamic block. D

Ni33Option: A
Nov 9, 2023

A is the correct answer.

biprodattaOption: A
Jan 15, 2024

dynamic doesn't create nested block, for_each does