Back to course

The Workflow: Init

Infrastructure as Code (Terraform & OpenTofu Mastery)

Step 1: Initialize

In the directory where you created main.tf, run: bash tofu init

What happens?

  1. Provider Download: It looks at your code, sees you need the local provider, and downloads the binary from the registry.
  2. Backend Setup: It prepares the place where it will store information about your infrastructure.
  3. Lock File: It creates .terraform.lock.hcl to ensure everyone on your team uses the same provider version.

Always run init when you add new providers or clones a project.