DEV Community

Ty Foster
Ty Foster

Posted on

Terraform on Windows 11: The "Before You Start" Guide

Before the Terraform Magic Happens...

In one of my team meetings recently, one of the junior members of the team asked about the install troubles he was having, I realized that I even had some issues installing the basic files needed. Even for experienced engineers, the actual installation and basic configuration on Windows 11 can be a bit of a hurdle. Here is exactly how to get your environment ready.

## Prerequisites
The assumption is you already have an Azure account. If you don't, sign up here for a free account.


## Method 1: Manual Installation
The best place to start is the official HashiCorp site.

  1. Download: Go to the Terraform Downloads page.

Terraform Windows versions

  1. Choose your Version:
    • 386: For 32-bit systems.
    • AMD64: For 64-bit systems (Most modern Windows 11 laptops).
  2. Extract: Right-click the downloaded zip and extract terraform.exe.

### Setting the Path

  1. Create a folder (e.g., C:\terraform) and move the .exe there.
  2. Click the Start Menu and type "Environment Variables". Environmental Variables start menu
  3. Under System Variables, find Path, click Edit, and add C:\terraform. System variables path to add path to terraform.exe

Add C:/terraform path

### Testing your Terraform configuration
Test your terraform install by opening up PowerShell and type terraform.
PowerShell window type terraform to confirm install


## Method 2: The "Chocolatey" Way (Recommended)
If you prefer a package manager, this is much faster.

## Prerequisites
PowerShell, run as administrator. This is installed by default so 1 less install yey!!
But just in case you want to run PowerShell 7 go
PowerShell.

Get chocolatey.
you will need to run a few PowerShell commands during this step but the steps are pretty straight forward to complete.

### 1. Setup PowerShell
Launch PowerShell as Administrator and check your execution policy:

Get-ExecutionPolicy

PowerShell prompt to show get execution policy
If it returns the above run the following command

Set-ExecutionPolicy AllSigned
PowerShell prompt to show set execution policy

Or run this command

Set-ExecutionPolicy Bypass -Scope Process

PowerShell prompt to show Set-ExecutionPolicy Bypass -Scope Process

### 2. Install Chocolatey

Run the following command to install Chocolatey

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

### 3. Test your Chocolatey install
Test your install for chocolatey by opening up PowerShell
and type the following command
choco
PowerShell command to show choco installation

After you see the above run the following command to install terraform

choco install terraform

PowerShell command to run choco install terraform

Once installed check terraform installation by running the following command

terraform

test to check terraform install is complete

Once you see the above you are ready to Terraform like a champ!!!

Until next time Terraformers

Top comments (0)