Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 129 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 129
Topic #: 1
[All Terraform Associate Questions]

You are using a networking module in your Terraform configuration with the name label my_network. In your main configuration you have the following code:

When you run terraform validate, you get the following error:

What must you do to successfully retrieve this value from your networking module?

  • A. Define the attribute vnet_id as a variable in the networking module
  • B. Change the referenced value to module.my_network.outputs.vnet_id
  • C. Define the attribute vnet_id as an output in the networking module
  • D. Change the referenced value to my_network.outputs.vnet_id
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
zyxphreez
Highly Voted 2 years, 2 months ago
Selected Answer: C
In a parent module, outputs of child modules are available in expressions as module.<MODULE NAME>.<OUTPUT NAME>. For example, if a child module named web_server declared an output named instance_ip_addr, you could access that value as module.web_server.instance_ip_addr. Answer is C
upvoted 21 times
...
RVivek
Highly Voted 2 years, 1 month ago
Selected Answer: C
Create an out put in child module and resfrence that as module.<MODULE NAME>.<OUTPUT NAME>
upvoted 5 times
...
Bere
Most Recent 10 months, 1 week ago
Selected Answer: A
Answer is A In Terraform versions 0.11 and earlier, you would use the interpolation syntax with ${} to reference attributes: # Terraform 0.11 and earlier output "instance_ip_addr" { value = "${aws_instance.main.private_ip}" } Starting with Terraform 0.12, interpolation is not needed for simple references, so you can directly reference the attribute: # Terraform 0.12 and later output "instance_ip_addr" { value = aws_instance.main.private_ip }
upvoted 4 times
...
Bere
10 months, 1 week ago
Selected Answer: C
Answer is C Define the attribute vnet_id as an output in the networking module. In the Child Module (my_network), if you had a resource defined as aws_vpc and named it example_vpc, you would reference its ID like this: # In your networking module's outputs.tf or main.tf file output "vnet_id" { description = "The ID of the created VNet" value = aws_vpc.example_vpc.id # Replace example_vpc with the actual name of your VPC resource } In the Parent Module (main configuration): output "net_id" { value = module.my_network.vnet_id }
upvoted 3 times
...
Jayanth
1 year, 4 months ago
C is the right answer
upvoted 1 times
...
Williamus
1 year, 8 months ago
Selected Answer: C
All looks good except that the output in the child module is missing.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...