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
- Download Terraform
- Unzip and Rename the Folder
- Move Terraform to Local Disk C
- Add Terraform to Environment Variables
- Verify Terraform Installation
- Create a
main.tf
File in VS Code
πΉ 1. Download Terraform
- Open your browser and go to the official Terraform download page.
- Scroll down to the Windows section.
- Click on the appropriate version (64-bit recommended) to start the download.
πΉ 2. Unzip and Rename the Folder
After downloading the Terraform ZIP file:
- Locate the downloaded
.zip
file in your Downloads folder. - Right-click the file and select Extract Allβ¦
- Rename the extracted folder to
terraform
.
πΉ 3. Move Terraform to Local Disk C
To ensure Terraform is accessible system-wide:
- Cut the
terraform
folder. - Navigate to
Local Disk (C:)
. - Paste the
terraform
folder insideC:\
.
πΉ 4. Add Terraform to Environment Variables
To run Terraform commands globally, we need to add it to the system's PATH:
- Press
Win + R
, typesysdm.cpl
, and press Enter. - Go to the Advanced tab and click Environment Variables.
- Under System Variables, find and select Path, then click Edit.
- Click New and enter the Terraform folder path:
C:\terraform
- Click OK on all windows to save the changes.
πΉ 5. Verify Terraform Installation
To check if Terraform is installed correctly:
- Open Command Prompt (CMD) by pressing
Win + R
, typingcmd
, and hitting Enter. - Run the following command:
terraform -v
If the installation was successful, you should see the Terraform version displayed.
πΉ 6. Create a main.tf
File in VS Code
Now, let's set up a simple Terraform configuration file:
- Open VS Code.
- Create a new folder for your Terraform project (e.g.,
terraform-project
). - Inside the folder, create a new file named
main.tf
. - Open
main.tf
and add the following sample Terraform configuration:
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0"
}
}
}
provider "azurerm" {
features {}
}
- Save the file.
π― 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! π
Top comments (0)