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 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: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
franksoul
Highly Voted 2 years, 5 months ago
Dear ALL, tested in Lab and Answer is : B
upvoted 28 times
...
bigboi23
Highly Voted 2 years, 6 months ago
Selected Answer: B
B!!!!!!!!
upvoted 15 times
...
nmnm22
Most Recent 3 months, 2 weeks ago
why is it index number AND name, though? i would have thought that specifying the index number is enough
upvoted 1 times
...
nhaastrup
6 months, 3 weeks 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 3 times
...
kingfighers
7 months, 3 weeks 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 2 times
...
samimshaikh
10 months, 4 weeks ago
Selected Answer: B
because the index starts from 0 so second instance name will be at 1
upvoted 4 times
...
gofavad926
1 year, 1 month ago
Selected Answer: B
B for sure
upvoted 1 times
...
debabrata6983
1 year, 2 months ago
Selected Answer: B
This is the very basics of terraform resource referencing
upvoted 3 times
...
Bere
1 year, 3 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 8 times
...
Bluemoon22
1 year, 7 months ago
The answer is B, aws_instance.web[1].name
upvoted 5 times
...
Power123
1 year, 7 months ago
B is correct
upvoted 2 times
...
thor7
1 year, 7 months ago
Selected Answer: B
B is a correct answer, checked.
upvoted 1 times
...
Nunyabiznes
1 year, 8 months 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, 8 months ago
Selected Answer: B
its B - people who answer incorrectly with such conviction and belief are dangerous.
upvoted 4 times
...
oab720
1 year, 10 months ago
Selected Answer: B
Tried and tested, definitely B
upvoted 1 times
...
Bebins
1 year, 11 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, 11 months ago
Selected Answer: B
B is the correct answer
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 ...