HashiCorp Certified: Terraform Associate — Question 102
You want to tag multiple resources with a string that is a combination of a generated random_id and a variable.
How should you use the same value in all these resources without repeating the random_id and variable in each resource?
Answer options
- A. Local values
- B. Data source
- C. Modules
- D. Outputs
Correct answer: A
Explanation
The correct answer is A, Local values, because they allow you to define a value once and reference it multiple times within your configuration, eliminating redundancy. Options B (Data source), C (Modules), and D (Outputs) do not serve the same purpose; data sources retrieve information, modules encapsulate resources, and outputs are used to display results after execution.