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

How would you refer to the indexing instance from the below configuration?

    Correct Answer: D

    To refer to the “indexing” instance in Terraform using for_each, you must access the resource by including the key within square brackets. The correct syntax to refer to a specific instance when using for_each is to write the resource type, the resource name, and then the key in square brackets. Therefore, aws_instance.web[“indexing”] is the correct way to refer to the “indexing” instance.

Discussion
NunyabiznesOption: D

aws_instance.web["indexing"]

kareem_ashrafOption: D

Referring to Instances with multiple instances are prefixed with module.<NAME>[<KEY>] when displayed in plan output and elsewhere in the UI. For a module without count or for_each, the address will not contain the module index as the module's name suffices to reference the module.

March2023Option: D

Just tested, the answer is D

ArnaldoWOption: D

The correct one is D. It's involving for_each. In summary, both notations refer to the same resource instance but use different syntax to access it. The bracket notation is used for dynamic access, whereas the dot notation is used for direct access.

d9iceguyOption: D

D is correct https://developer.hashicorp.com/terraform/language/meta-arguments/for_each#referring-to-instances

styroOption: D

D. aws_instance.web[“indexing”] To refer to the “indexing” instance in the given configuration, you would use the resource type followed by the resource name, and then use the index key in square brackets. The correct syntax is: aws_instance.web["indexing"] This refers to the “indexing” instance created by the aws_instance resource named “web”. The other options provided do not use the correct syntax for referencing resources with for_each keys in Terraform.

tbhtpOption: B

The correct answer is B.

hahanoOption: B

the answer is B