Skip to main content
OpenTofu relies on a plugin-based architecture to manage providers, enabling you to provision resources across AWS, GCP, Azure, and many more platforms. This guide covers how to initialize your working directory, understand provider types, and reference provider plugins in your configurations.

1. Initializing Your Directory

Run the following command in a directory containing your OpenTofu configuration files:
When executed against valid .tf files, tofu init will:
  • Install all required provider plugins.
  • Create a lock file (.terraform.lock.hcl) to pin provider versions.
  • Ensure idempotent behavior: rerunning does not alter existing infrastructure.
Always commit the .terraform.lock.hcl file to your VCS. This ensures consistent provider versions across environments.
Plugins are stored under the hidden directory .terraform/providers in your working directory.

2. Provider Types

Providers are distributed via Terraform Registry and OpenTofu Registry, and fall into three categories:
The image is a diagram showing HashiCorp's providers, including AWS, Google Cloud, Azure, and others, leading to the Terraform and OpenTofu registries.

3. Plugin Naming Conventions

Each provider is referenced by a source address with this structure:
  • hostname (optional): Defaults to registry.opentofu.org if omitted.
  • namespace: Organization or author (e.g., hashicorp).
  • type: Provider name (e.g., aws, local).

Examples

Using the default registry:
Using the fully qualified address:

4. References

Watch Video