Free HashiCorp Terraform-Associate-003 Exam Actual Questions

The questions for Terraform-Associate-003 were last updated On Jan 16, 2025

Question No. 1

What is the Terraform style convention for indenting a nesting level compared to the one above it?

Show Answer Hide Answer
Correct Answer: A

Terraform's Indentation Standards: Terraform's style convention uses two spaces per nesting level for readability, helping to maintain uniform code across teams.

Configuration Files: Consistent indentation is crucial for Terraform's HCL syntax, as it improves readability and avoids parsing issues.

More details are available in the Terraform configuration style guide.


Question No. 2

Which Terraform collection type should you use to store key/value pairs?

Show Answer Hide Answer
Correct Answer: B

The Terraform collection type that should be used to store key/value pairs is map. A map is a collection of values that are accessed by arbitrary labels, called keys. The keys and values can be of any type, but the keys must be unique within a map. For example, var = { key1 = 'value1', key2 = 'value2' } is a map with two key/value pairs. Maps are useful for grouping related values together, such as configuration options or metadata.

References = [Collection Types], [Map Type Constraints]


Question No. 3

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?

Show Answer Hide Answer
Correct Answer: D

Dynamic blocks in Terraform allow you to define multiple nested blocks within a resource based on the values of a variable. This feature is particularly useful for scenarios where the number of nested blocks is not fixed and can change based on variable input.


Question No. 4

What feature stops multiple users from operating on the Terraform state at the same time?

Show Answer Hide Answer
Correct Answer: A

State locking prevents other users from modifying the state file while a Terraform operation is in progress. This prevents conflicts and data loss1.


Question No. 5

Your root module contains a variable named num_servers. Which is the correct way to pass its value to a child module with an input named servers?

Show Answer Hide Answer
Correct Answer: C

The correct syntax to pass a variable from the root module to a child module is servers = var.num_servers. Terraform uses dot notation to reference variables.

References:

Terraform Variables