Terraform Tutorial — Installing Terraform
This chapter walks you through installing Terraform, setting up cloud credentials, configuring your editor, and organizing your project directory. By the end, you’ll be ready to write and run your first Terraform configuration.
What’s in this Chapter?
| # | Topic | Description |
|---|---|---|
| 1 | Install on Linux | apt/yum repo, manual binary, tfenv |
| 2 | Install on macOS & Windows | Homebrew, Chocolatey, WSL2 |
| 3 | Setting Up Cloud Credentials | AWS, GCP, Azure credential setup |
| 4 | VS Code & HashiCorp Extension | Syntax highlighting, auto-complete |
| 5 | Project Directory Layout | Standard file layout, .gitignore |
| 6 | Practice Exercises | Hands-on installation verification |
Chapter Overview
Before you write any Terraform code, you need three things: the Terraform CLI on your machine, credentials to talk to a cloud provider, and a text editor that understands HCL. This chapter covers all three.
We’ll also cover tfenv (a version manager that lets you switch between Terraform versions), the standard project directory layout that most teams use, and the files you should never commit to Git.
Key Concepts Preview
| Term | Definition |
|---|---|
| Terraform CLI | The binary you install — the terraform command |
| tfenv | A version manager for Terraform (like nvm for Node.js) |
| Cloud credentials | API keys or IAM roles that authorize Terraform to create resources |
| Provider | A plugin downloaded by terraform init that talks to a specific cloud |
.terraform/ |
Local cache of downloaded providers (never commit to Git) |
.terraform.lock.hcl |
Dependency lock file (should commit to Git) |
What You’ll Be Able to Do After This Chapter
- Install Terraform on Linux, macOS, or Windows
- Verify your installation with
terraform version - Configure cloud credentials for AWS, GCP, or Azure
- Set up VS Code with HCL syntax highlighting and auto-complete
- Create a properly organized Terraform project directory
- Know which files to commit and which to
.gitignore