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

You are writing a child Terraform module which provisions an AWS instance. You want to make use of the IP address returned in the root configuration. You name the instance resource "main".

Which of these is the correct way to define the output value using HCL2?

A.

B.

    Correct Answer:

    The correct way to define the output value using HCL2 is to use the provided syntax of 'value = aws_instance.main.private_ip' without the interpolation syntax using ${}. Therefore, the correct answer is option A, but with the updated HCL2 syntax. Option A correctly uses a 'value' attribute, while option B incorrectly uses 'return', which is not valid in Terraform configuration.

Discussion
keiffo2

Has to be Answer A. no such definition as "return"

Bere

Answer is A In Terraform versions 0.11 and earlier, you would use the interpolation syntax with ${} to reference attributes: # Terraform 0.11 and earlier output "instance_ip_addr" { value = "${aws_instance.main.private_ip}" } Starting with Terraform 0.12, interpolation is not needed for simple references, so you can directly reference the attribute: # Terraform 0.12 and later output "instance_ip_addr" { value = aws_instance.main.private_ip }

MauroSoli

Answer is A but syntax is deprecated

syam22587

A is correct answer

junk4share

A is correct.

phidelics

The answer is A

kennynelcon

A is accurate