HashiCorp
TERRAFORM-ASSOCIATE-003 · Question #190
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 answer is C. servers = var.num_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.
Interact with Terraform Modules
Question
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?
Options
- Aservers = num_servers
- Bservers = var(num_servers)
- Cservers = var.num_servers
- Dservers = ${var.num_servers}
How the community answered
(40 responses)- A3% (1)
- B10% (4)
- C80% (32)
- D8% (3)
Explanation
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.
Topics
#module variables#variable references#child modules#HCL syntax
Community Discussion
No community discussion yet for this question.