What is the Terraform style convention for indenting a nesting level compared to the one above it?
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.
Which Terraform collection type should you use to store key/value pairs?
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]
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?
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.
What feature stops multiple users from operating on the Terraform state at the same time?
State locking prevents other users from modifying the state file while a Terraform operation is in progress. This prevents conflicts and data loss1.
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?
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