Sling Academy
Home/DevOps/3 ways to install Terraform on Windows

3 ways to install Terraform on Windows

Last updated: February 03, 2024

Introduction

Installing Terraform on Windows is a critical first step for infrastructure automation and management. Terraform, by HashiCorp, is an open-source tool that allows users to build, change, and version infrastructure safely and efficiently. This guide will walk you through several methods to install Terraform on Windows, catering to different preferences and requirements.

Solution 1: Using Chocolatey

Chocolatey is a Windows package manager that simplifies the process of managing software installations. With it, installing Terraform becomes a simple, one-command affair.

  1. Ensure that you have Chocolatey installed on your Windows machine. If not, visit https://chocolatey.org/install for installation instructions.
  2. Open a PowerShell or Command Prompt as Administrator.
  3. Type the command: choco install terraform and hit Enter.
  4. Wait for the process to complete.

The output will be a confirmation that Terraform has been installed.

Notes: Using Chocolatey is an easy and fast method to install Terraform, but it relies on Chocolatey’s package repository to be up to date. The version of Terraform installed may not always be the latest.

Solution 2: Manual Installation

For those who prefer a more hands-on approach or need a specific version of Terraform, manual installation is an option. This involves downloading the Terraform binary and adding it to your system’s PATH.

  1. Visit the Terraform website (https://www.terraform.io/downloads.html) and download the latest version of Terraform for Windows.
  2. Extract the ZIP file to a folder of your choice, e.g., C:\Terraform.
  3. Add the folder where you extracted Terraform to your system’s PATH environment variable. This can be done through the System Properties -> Environment Variables dialog in Windows.
  4. Open a new Command Prompt or PowerShell window and type terraform version to verify the installation.

Notes: Manual installation allows for greater control over the installed version of Terraform but requires manual updates. This method is best for users who need specific versions or appreciate full control over their tools.

Solution 3: Using Scoop

Scoop is another command-line installer for Windows that focuses on making it easy to install and manage software without the need for administrator access.

1. First, install Scoop by opening PowerShell and typing:

Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh') 

2. Once Scoop is installed, you can install Terraform by typing:

scoop install terraform 

Like Chocolatey, the output will indicate successful installation of Terraform.

Notes: Scoop offers an easy installation process and the convenience of user-level installations (no administrator access required). However, similar to Chocolatey, you may not always get the absolute latest version of Terraform.

Conclusion

Each method of installing Terraform on Windows has its benefits and drawbacks. Chocolatey and Scoop offer quick and easy installations but may not always feature the very latest version. Manual installation gives users full control over the version and installation process but requires a bit more effort to install and update. Ultimately, the best choice depends on your individual needs and preferences for managing software on Windows.

Next Article: 3 ways to install Terraform on Mac

Previous Article: When NOT to use Terraform (and what to use instead)

Series: Terraform Tutorials

DevOps

You May Also Like

  • How to reset Ubuntu to factory settings (4 approaches)
  • Making GET requests with cURL: A practical guide (with examples)
  • Git: What is .DS_Store and should you ignore it?
  • NGINX underscores_in_headers: Explained with examples
  • How to use Jenkins CI with private GitHub repositories
  • Terraform: Understanding State and State Files (with Examples)
  • SHA1, SHA256, and SHA512 in Terraform: A Practical Guide
  • CSRF Protection in Jenkins: An In-depth Guide (with examples)
  • Terraform: How to Merge 2 Maps
  • Terraform: How to extract filename/extension from a path
  • JSON encoding/decoding in Terraform: Explained with examples
  • Sorting Lists in Terraform: A Practical Guide
  • Terraform: How to trigger a Lambda function on resource creation
  • How to use Terraform templates
  • Understanding terraform_remote_state data source: Explained with examples
  • Jenkins Authorization: A Practical Guide (with examples)
  • Solving Jenkins Pipeline NotSerializableException: groovy.json.internal.LazyMap
  • Understanding Artifacts in Jenkins: A Practical Guide (with examples)
  • Using Jenkins with AWS EC2 and S3: A Practical Guide