This guide explains how to use OpenTofu providers for resource provisioning across various platforms.
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.
Run the following command in a directory containing your OpenTofu configuration files:
Copy
Ask AI
tofu init
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.
Copy
Ask AI
$ tofu initInitializing the backend...Initializing provider plugins...- Finding the latest version of hashicorp/local...- Installing hashicorp/local v2.4.1...- Installed hashicorp/local v2.4.1 (signed, key ID 0C0AF313E5FD9F80)Providers are signed by their developers.If you'd like to know more about provider signing, see: https://opentofu.org/docs/cli/plugins/signing/OpenTofu has created a lock file .terraform.lock.hcl to record the providerselections it made above. Include this file in your version control repositoryso that OpenTofu can guarantee the same selections next time you run "tofu init".OpenTofu has been successfully initialized!
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.