random provider. By the end, you’ll be able to expose resource attributes and query them on demand.
1. Setup and Resource Configuration
-
Change into the sample project directory:
-
Examine the HCL files defining nine resources with the random provider:
-
Open the accompanying
output.tfto see how each resource is exposed as an output variable.
2. Initialize, Plan, and Apply
Initialize the working directory, preview the plan, and apply the configuration.You can learn more about OpenTofu and output variables in the official Terraform Output Variables documentation.
3. Querying Individual Outputs
Test your understanding:-
What is the value of
id2?
From the example above,id2 = "9687669a-73d4-9717-52a2-6497826815a1". -
What is the value of
order1?
It is16106.
4. Inspecting a New Configuration
Switch to the second lab directory and reviewmain.tf:
main.tf, you’ll find:
If the image below doesn’t render, use the code snippet above to verify your setup.

5. Adding a New Output Variable
The samemain.tf defines a local_file resource:
content: