fbpx

Install Terraform on Windows: Step-by-Step Guide

Terraform is a powerful Infrastructure as Code (IaC) tool used to manage cloud resources efficiently. In this guide, you’ll learn how to install Terraform on your Windows machine. Let’s get started!

✅ Step 1: Download Terraform

  1. Visit the official Terraform website: Terraform Downloads

  2. Select Windows and choose the appropriate version (typically amd64 for most users).

  3. Click Download and save the file.

📥 Once the download completes, proceed to the next step.

📦 Step 2: Extract the Terraform Files

  1. Locate the downloaded .zip file.

  2. Use a tool like WinRAR, 7-Zip, or Windows Extractor to extract the contents.

  3. You will find a single file named terraform.exe.

  💡 Tip: Create a dedicated folder like C:\terraform and move  terraform.exe there.

⚙️ Step 3: Add Terraform to System Path

To run Terraform from any command prompt, add it to your system’s Path variable.

  1. Search for Environment Variables from the Start Menu.

  2. Click on Edit the system environment variablesEnvironment Variables.

  3. Under System Variables, locate the variable named Path and click Edit.

  4. Click New and enter the path where you placed terraform.exe (e.g., C:\terraform).

  5. Click OK to save the changes.

🧑‍💻 With this done, Terraform is now accessible from your terminal.

🧪 Step 4: Verify Installation

Now it’s time to check if Terraform is installed correctly.

  1. Open Command Prompt or PowerShell.

  2. Run the following command:

terraform version

  1. You should see the installed Terraform version displayed.

🎉 Congratulations! Terraform is successfully installed.

🚀 Bonus: Install Using Chocolatey (Optional)

If you have Chocolatey installed, you can install Terraform with one command:

choco install terraform

This method is faster and automatically adds Terraform to your system path.

🙌 Next Steps

Now that you have Terraform installed, you can start building and managing cloud infrastructure. Try running:

terraform init

🏁 Run Your First Terraform Script

Here is a simple example to create two AWS EC2 instances using Terraform.

1.Create a new directory and navigate to it:

mkdir terraform-aws-demo
cd terraform-aws-demo

2.Create a file named main.tf and add the following content:

provider “aws” {
        region = “us-east-1”
        access_key = “YOUR_ACCESS_KEY”
        secret_key = “YOUR_SECRET_KEY”
}

resource “aws_instance” “myfirstVM” {
        count = 2
        ami = “ami-08b5b3a93ed654d19”
        instance_type = “t2.micro”
        key_name = “terraformserverkey”
tags = {
       Name = “linuxserver”
    }
}

⚠️ Ensure your access and secret keys are correct. Never share your keys publicly.

3.Initialize and apply the configuration:

terraform init
terraform apply

4 .Confirm with yes when prompted.

✅ Your AWS EC2 instances will be created shortly. Congratulations on running your first Terraform script!

💬 Need help? Drop your questions in the comments!

DevOps with AWS Training

Take your DevOps skills to the next level with our AWS training! Gain hands-on experience, real-world project exposure, and industry-recognized expertise. Enroll today and step into a high-demand career

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat
Hello, Good day!!
How can we help you?