Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 57

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

    Correct Answer: B

    In Terraform, when using the count argument in a resource block, the instances are indexed starting from 0. To reference the 'name' value of the second instance, you would use the 1-based index, which corresponds to the 0-based index used internally by Terraform. Therefore, the correct reference to the 'name' value of the second instance would be aws_instance.web[1].name, utilizing the appropriate index.

Discussion
franksoulOption: B

Dear ALL, tested in Lab and Answer is : B

bigboi23Option: B

B!!!!!!!!

NunyabiznesOption: 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.

BereOption: B

Example: resource "aws_instance" "web" { count = 2 name = "terraform-${count.index}" } output "second_instance_name" { value = aws_instance.web[1].name }

Bluemoon22Option: B

The answer is B, aws_instance.web[1].name

samimshaikhOption: B

because the index starts from 0 so second instance name will be at 1

Ell89Option: B

its B - people who answer incorrectly with such conviction and belief are dangerous.

nhaastrupOption: B

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

debabrata6983Option: B

This is the very basics of terraform resource referencing

kingfighersOption: D

A. element(aws_instance.web, 2) is correct if we want to access the 3rd one, but there is no "the third one"

Power123Option: B

B is correct

gofavad926Option: B

B for sure

thor7Option: B

B is a correct answer, checked.

oab720Option: B

Tried and tested, definitely B

BebinsOption: B

The output of A won't return the name of the 2nd instance. So here the answer is "B"

adoubanOption: B

B is the correct answer

asudhinOption: B

It is B