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! πŸ‘‡

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo πŸ“Šβœ¨

Top comments (0)

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong Β· web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌢️πŸ”₯

πŸ‘‹ Kindness is contagious

If you enjoyed this read, please hit a ❀️ or drop a kind comment!

Great!