ExamGecko
Question list
Search
Search

Question 153 - Terraform Associate 003 discussion

Report
Export

How would you reference the 'name'' value of the second instance of this resource?

A.
aws_instance.web(2),name
Answers
A.
aws_instance.web(2),name
B.
element(aws_instance.web, 2)
Answers
B.
element(aws_instance.web, 2)
C.
aws_instance-web(1)
Answers
C.
aws_instance-web(1)
D.
aws_instance_web(1),name
Answers
D.
aws_instance_web(1),name
E.
Aws_instance,web,* , name
Answers
E.
Aws_instance,web,* , name
Suggested answer: D

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.

Terraform documentation on count and accessing resource instances: Terraform Count

asked 18/09/2024
Junaid Sahebzada
33 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first