Skip to main content
In this lesson, we will:
  1. Inspect an OpenTofu configuration directory
  2. Count providers, configuration files, and resources
  3. Create local file resources
  4. Identify provider modules in specific directories

Prerequisites

Ensure you have OpenTofu installed and accessible in your $PATH. We will work under:
Initially, this directory contains only main.tf.
Always run opentofu init before performing other commands to download necessary provider plugins and create the .terraform folder.

1. Counting Providers, Files, and Resources

Before running any commands, let’s answer a few questions: main.tf resource blocks:
The image shows a coding environment with a file explorer displaying a directory structure and a code editor with Terraform configuration files. A question about the version of a plugin for a local provider is visible on the left.

2. Creating Local File Resources

Apply the configuration:
Confirm with yes. This will create:
  • /root/things-to-do.txt
  • /root/more-things-to-do.txt

3. Working with a New Configuration Directory

Create or navigate to:
It contains two files: cyberpunk.tf and ps5.tf. Each defines a local_file resource. cyberpunk.tf
ps5.tf
Total resources: 2
cyberpunk resource filename: /root/cyberpunk2077.txt

3.1 Adding an Xbox Resource

Create xbox.tf in the same directory:
Then run:
Confirm with yes to add /root/xbox.txt.

4. Identifying Provider Modules

We have two provider directories to inspect: Example snippet from providerA/required_providers:

References

Watch Video

Practice Lab