DEV Community

Cover image for How to Install and Set Up Terraform on Windows (Step-by-Step Guide)
kristarking
kristarking

Posted on

1

How to Install and Set Up Terraform on Windows (Step-by-Step Guide)

Terraform is a powerful Infrastructure as Code (IaC) tool that allows you to manage cloud resources efficiently. In this guide, we'll walk through installing Terraform on Windows, configuring environment variables, verifying the installation, and creating a simple main.tf file in VS Code.


πŸ“Œ Table of Contents

  1. Download Terraform
  2. Unzip and Rename the Folder
  3. Move Terraform to Local Disk C
  4. Add Terraform to Environment Variables
  5. Verify Terraform Installation
  6. Create a main.tf File in VS Code

πŸ”Ή 1. Download Terraform

  1. Open your browser and go to the official Terraform download page.
  2. Scroll down to the Windows section.
  3. Click on the appropriate version (64-bit recommended) to start the download.

πŸ”Ή 2. Unzip and Rename the Folder

After downloading the Terraform ZIP file:

  1. Locate the downloaded .zip file in your Downloads folder.
  2. Right-click the file and select Extract All…
  3. Rename the extracted folder to terraform.

Google search terraform Image description

Google 2 Image description

Zip Image description

πŸ”Ή 3. Move Terraform to Local Disk C

To ensure Terraform is accessible system-wide:

  1. Cut the terraform folder.
  2. Navigate to Local Disk (C:).
  3. Paste the terraform folder inside C:\.

Terraform folder Image 1 description

Terraform folder Image 2 description

Terraform folder Image description 3

Terraform folder Image description 4

Terraform folder Image description 5

Terraform folder Image description 6

πŸ”Ή 4. Add Terraform to Environment Variables

To run Terraform commands globally, we need to add it to the system's PATH:

  1. Press Win + R, type sysdm.cpl, and press Enter.
  2. Go to the Advanced tab and click Environment Variables.
  3. Under System Variables, find and select Path, then click Edit.
  4. Click New and enter the Terraform folder path:
   C:\terraform
Enter fullscreen mode Exit fullscreen mode
  1. Click OK on all windows to save the changes.

Terraform 1Image description

Terraform 2Image description

Terraform 3Image description

Terraform 4Image description

Terraform 5Image description
Terraform 6Image description

πŸ”Ή 5. Verify Terraform Installation

To check if Terraform is installed correctly:

  1. Open Command Prompt (CMD) by pressing Win + R, typing cmd, and hitting Enter.
  2. Run the following command:
   terraform -v
Enter fullscreen mode Exit fullscreen mode

If the installation was successful, you should see the Terraform version displayed.


CMD Image description

πŸ”Ή 6. Create a main.tf File in VS Code

Now, let's set up a simple Terraform configuration file:

  1. Open VS Code.
  2. Create a new folder for your Terraform project (e.g., terraform-project).
  3. Inside the folder, create a new file named main.tf.
  4. Open main.tf and add the following sample Terraform configuration:
   terraform {
     required_providers {
       azurerm = {
         source  = "hashicorp/azurerm"
         version = "~> 3.0"
       }
     }
   }

   provider "azurerm" {
     features {}
   }
Enter fullscreen mode Exit fullscreen mode
  1. Save the file.

VS Image description

🎯 Conclusion

Congratulations! πŸŽ‰ You have successfully installed Terraform on Windows, configured environment variables, verified the installation, and created your first Terraform configuration file in VS Code.

Now you're ready to start deploying infrastructure using Terraform! πŸš€

Let me know in the comments if you encountered any issues! πŸ‘‡

Heroku

Amplify your impact where it matters most β€” building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

If you found this post useful, please drop a ❀️ or leave a kind comment!

Okay