HashiCorp Certified: Terraform Associate — Question 8
Which of the following is the correct way to pass the value in the variable num_servers into a module with the input servers?
Answer options
- A. servers = num_servers
- B. servers = variable.num_servers
- C. servers = var(num_servers)
- D. servers = var.num_servers
Correct answer: D
Explanation
The correct answer is D because it correctly references the num_servers variable as an attribute of the var object. Option A incorrectly tries to directly assign the variable without referencing its container, while B uses 'variable' instead of 'var', and C incorrectly uses a function call syntax that is not applicable here.