nerdexam
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)
  • A
    3% (1)
  • B
    10% (4)
  • C
    80% (32)
  • D
    8% (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.

Full TERRAFORM-ASSOCIATE-003 Practice