Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 17


If a module uses a local values, you can expose that value with a terraform output.

Show Answer
Correct Answer: A

In Terraform, output values serve the purpose of sharing data between modules and even between separate configurations. These outputs are similar to return values in programming and can be used to expose important information. Local values, while typically used internally within modules, can indeed be exposed through an output block, allowing other parts of the configuration to consume this information. Therefore, the statement is true.

Discussion

16 comments
Sign in to comment
BereOption: A
Jul 28, 2023

Code example: variable "input" { description = "An input variable" default = "Hello" } locals { local_value = "${var.input}, World!" } output "greeting" { description = "A greeting message" value = local.local_value } Outputs: greeting = "Hello, World!"

daawwOption: A
Sep 9, 2022

A is correct

SilentMilliOption: A
Feb 11, 2023

If a module uses local values, those values can be exposed using the "terraform output" directive. By using the terraform output directive, you can define an output for a module that provides information about the local values used within the module. This information can then be consumed by other parts of the Terraform configuration, allowing you to make use of the values that have been set within the module. To expose a local value, you would define an output block in the module, specifying the name and value of the output, and then reference the output in other parts of your Terraform configuration using the "terraform output" data source.

poojithakadiyalaOption: A
Sep 28, 2022

A is correct

hectordjOption: A
Oct 18, 2022

A is correct

jj22222Option: A
Oct 27, 2022

A is correct

ssanjaytOption: A
Jan 12, 2023

A is correct

TanacetOption: A
Jan 28, 2023

It is A

gargadityaOption: A
Mar 16, 2023

1. Output values make information about your infrastructure available on the command line, and can expose information for other Terraform configurations to use. Output values are similar to return values in programming languages. 2.Basic Syntax: https://drive.google.com/file/d/1td5DcyZ-7iHL3Xhpwep4deEEfKbC7DkT/view?usp=sharing 3.Using Output Values with Modules(logical concept described in diagram below): https://drive.google.com/file/d/1tbYWsCSev063ibz9Pv9poqViOY6fAAsG/view?usp=sharing Basically,the question is narrowed down to exposing locals from the root module(can be any resource attribute in general).

karendavtyanOption: A
May 5, 2023

A. true

IK912Option: A
Jun 18, 2023

Answer Definitely A

SammySunnyOption: B
Jun 25, 2023

Why not B? The documentation says "A local value can only be accessed in expressions within the module where it was declared"

HMthyl
Jul 12, 2023

Confirmed using a project, A is true. That definition threw me too - but if you explicitly output the local value it can be accessed as expected

VSMuOption: A
Jul 13, 2023

Answer A. # Output the local variable as an output value output "instance_public_ip" { value = local.instance_public_ip }

Busi57Option: A
Jul 23, 2023

Teams A

JayanthOption: A
Jul 28, 2023

A. True

HarshPatel198Option: A
Aug 25, 2023

Bere is right