Back to course

Formatting and Linting

Infrastructure as Code (Terraform & OpenTofu Mastery)

Clean Code is a Requirement

In a team, everyone should use the same style. OpenTofu has a built-in tool for this.

Commands

  1. tofu fmt: Automatically fix indentation and spacing.
  2. tofu validate: Check if the code is logically correct before running a plan.

Always run tofu fmt before committing code to Git.