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

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 57 discussion

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

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

  • A. element(aws_instance.web, 2)
  • B. aws_instance.web[1].name
  • C. aws_instance.web[1]
  • D. aws_instance.web[2].name
  • E. aws_instance.web.*.name
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️
Reference:
https://www.terraform.io/docs/configuration-0-11/interpolation.html

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
franksoul
Highly Voted 1 year, 11 months ago
Dear ALL, tested in Lab and Answer is : B
upvoted 22 times
...
bigboi23
Highly Voted 1 year, 11 months ago
Selected Answer: B
B!!!!!!!!
upvoted 15 times
...
nhaastrup
Most Recent 5 days, 6 hours ago
To reference the "name" value of the second instance of the fictitious resource "aws_instance" named "server", you can use the element index notation in Terraform. The element index notation allows you to access elements in a list or collection by their index. Given that the index in Terraform starts from 0, the second instance has an index of 1. Therefore, to reference the "name" value of the second instance = B
upvoted 1 times
...
kingfighers
1 month ago
A. element(aws_instance.web, 2) is correct if we want to access the 3rd one, but there is no "the third one"
upvoted 1 times
...
samimshaikh
4 months, 1 week ago
Selected Answer: B
because the index starts from 0 so second instance name will be at 1
upvoted 4 times
...
gofavad926
7 months, 1 week ago
Selected Answer: B
B for sure
upvoted 1 times
...
debabrata6983
8 months, 1 week ago
Selected Answer: B
This is the very basics of terraform resource referencing
upvoted 3 times
...
Bere
9 months ago
Selected Answer: B
Example: resource "aws_instance" "web" { count = 2 name = "terraform-${count.index}" } output "second_instance_name" { value = aws_instance.web[1].name }
upvoted 6 times
...
Bluemoon22
1 year ago
The answer is B, aws_instance.web[1].name
upvoted 5 times
...
Power123
1 year, 1 month ago
B is correct
upvoted 2 times
...
thor7
1 year, 1 month ago
Selected Answer: B
B is a correct answer, checked.
upvoted 1 times
...
Nunyabiznes
1 year, 1 month ago
Selected Answer: B
The count.index starts from 0. Therefore, the second instance would have an index of 1. In that case, the correct answer would be B. aws_instance.web[1].name.
upvoted 9 times
...
Ell89
1 year, 1 month ago
Selected Answer: B
its B - people who answer incorrectly with such conviction and belief are dangerous.
upvoted 4 times
...
oab720
1 year, 3 months ago
Selected Answer: B
Tried and tested, definitely B
upvoted 1 times
...
Bebins
1 year, 4 months ago
The output of A won't return the name of the 2nd instance. So here the answer is "B"
upvoted 1 times
...
adouban
1 year, 4 months ago
Selected Answer: B
B is the correct answer
upvoted 1 times
...
asudhin
1 year, 7 months ago
Selected Answer: B
It is B
upvoted 1 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 ...