Skip to main content
In this hands-on lesson, you’ll explore HashiCorp Configuration Language (HCL) fundamentals using OpenTofu. You’ll identify resource types and names, initialize your working directory, and apply changes to a local file resource.

Q1: Identify the HCL File Extension

Navigate to your HCL project directory and list its contents:
Alternatively, open the folder in VS Code and observe that the filename is main.tf.
Answer: .tf

Q2: Determine the Resource Type

Inspect the resource block in main.tf:
Answer: local_file

Q3: Find the Resource Name

Within the same block, the second quoted identifier denotes the resource name:
Answer: games

Q4: Identify the Provider Name

The provider is indicated by the prefix of the resource type:
Here, local is the provider.
Answer: local

Q5: Valid vs. Invalid Arguments

The local_file resource supports only filename and content. It does not accept resource_type. Answer: resource_type = "local_file"

Q6: Why tofu plan Fails Initially

Running:
Produces:
The directory must be initialized first.
Always run tofu init before planning or applying any changes.

Initialize the Working Directory

You should see:

Q7: Locate the Provider Plugin Version

After initialization, OpenTofu downloads provider plugins. You can confirm the version (2.5.1) from the output or by inspecting .terraform:
The image shows a split screen with a multiple-choice question on the left asking about the version of a local provider plugin, and a code editor on the right displaying a Terraform configuration file.
Answer: 2.5.1

Q8: Re-run tofu plan with Incorrect Arguments

Results in:
You used file instead of filename and omitted filename.

Q9: Identify the Unsupported Argument

Referring to the Local Provider Documentation, file is not supported.
Answer: file

Q10: Correct the Configuration and Apply

Update main.tf:
Run:

Q11: Switch to a Sensitive File Resource

To mask content in plans, use local_sensitive_file:
Attempting to add an unsupported sensitive_content argument will fail:
Remove sensitive_content; it’s not supported.

Q12: Apply the Sensitive File Resource

With main.tf updated:
Run:
Plans will now hide the file’s content.

Q13: Destroy the Resource

Congratulations—you’ve completed the lab! 🎉

Watch Video

Practice Lab