TERRAFORM-ASSOCIATE-004 · Question #177
A resource block is shown in the Exhibit space of this page. How would you reference the "name'' value of the second instance of this resource?
The correct answer is D. aws_instance_web(1),name. In Terraform, when you use the count meta-argument, you can reference individual instances using an index. The indexing starts at 0, so to reference the "name" value of the second instance, you would use aws_instance.web[1].name. This syntax allows you to access the properties of
Question
Exhibit
Options
- Aaws_instance.web(2),name
- Belement(aws_instance.web, 2)
- Caws_instance-web(1)
- Daws_instance_web(1),name
- EAws_instance,web,* , name
How the community answered
(58 responses)- A9% (5)
- B2% (1)
- D86% (50)
- E3% (2)
Explanation
In Terraform, when you use the count meta-argument, you can reference individual instances using an index. The indexing starts at 0, so to reference the "name" value of the second instance, you would use aws_instance.web[1].name. This syntax allows you to access the properties of specific instances in a list generated by the count argument.
Topics
Community Discussion
No community discussion yet for this question.
