TERRAFORM-ASSOCIATE-003 · Question #177
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…
Question
How would you reference the "name'' value of the second instance of this resource?
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
(31 responses)- A10% (3)
- B13% (4)
- C3% (1)
- D71% (22)
- E3% (1)
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.