TERRAFORM-ASSOCIATE-003 practice question 13 of 30

[Understand Terraform Basics and CLI] What is one disadvantage of using dynamic blocks in Terraform?

Full set: 226 questions
Answer options
A: Dynamic blocks can construct repeatable nested blocks
B: Terraform will run more slowly
C: They cannot be used to loop through a list of values
D: They make configuration harder to read and understand Correct answer
Correct Answer:
D. They make configuration harder to read and understand
Explanation

While dynamic blocks are a powerful feature for creating multiple nested configuration blocks from a collection, their primary disadvantage is the potential to reduce the readability and maintainability of the code. They introduce a layer of abstraction; instead of seeing the configuration declared explicitly, a user must interpret the foreach loop and the content block to understand the final resulting infrastructure. The official Terraform documentation explicitly warns that overusing dynamic blocks can make configuration harder to read and maintain.

Why Incorrect

A. Constructing repeatable nested blocks is the main advantage and intended purpose of dynamic blocks, not a disadvantage.
B. There is no evidence in official documentation that using dynamic blocks inherently causes a significant slowdown in Terraform's execution.
C. This is factually incorrect. Dynamic blocks are specifically designed to iterate over collections like lists and maps using the foreach meta-argument.

References

1. HashiCorp. (n.d.). Dynamic Blocks. Terraform Documentation. Retrieved from https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks.

Reference Point: The documentation includes a specific note stating: "We recommend using dynamic blocks only when you need to dynamically generate arguments for a nested block. Overuse of dynamic blocks can make configuration hard to read and maintain." This directly supports option D as the correct answer. The page also demonstrates how dynamic blocks iterate over collections

which refutes option C and confirms the functionality described in option A.

Scroll to Top