How To Install Terraform On Windows
When I started learning Terraform, the outset thing I struggled with was getting proper instructions on how to install Terraform on my system or any deject server which I was using. There are many resources bachelor online that guide you through the installation steps, and of course Terraform docs also take a very good installation guide.
In this guide you will find all the necessary steps in one identify regardless of whether you are installing Terraform on Windows, Linux or macOS.
Prerequisites
Before you start the installation process, there are some prerequisites which y'all volition need to fulfill:
- A Windows PC if you are installing on Windows
- A Linux system (virtual or local) if yous are installing on Linux (in this post, I am using Ubuntu 20.04 to demonstrate the steps)
- Some basic CLI noesis
In this post, I volition be roofing the installation steps for Terraform on three different operating systems. You tin can follow the steps based on the system you are using. These are the high level topics I volition exist roofing in this mail service:
- Installing Terraform on Windows
- Installing Terraform on Linux (Ubuntu) using Parcel repository
- Installing Terraform on Linux using Zilch archive file
- Installing Terraform on macOS
How to Install Terraform on Windows
Let'due south outset with the nuts.
Download the installation file
1. Navigate to the Terraform download folio ( https://www.terraform.io/downloads.html ). It should list out Terraform downloads for various platforms. Navigate to the Windows section and download the respective version. For this example I am downloading V1.1.0.
2. It will download a zip file. Create a binder on the C drive as C:/terraform. Download the zip file in this folder. Unzip the file to excerpt the .exe file.
Update Path Environment Variable
ane. Next open up the Start menu and search for Environment variables. Open the Environs variables settings page.
2. On the Environment variables edit folio, open up the Path variable equally shown beneath:
3. On the opened Path pop up, click New and add the Terraform download folder. This is the folder where the zip file was downloaded and unzipped (C:/terraform).
4. Click OK on the above window to relieve the Path variable addition. If needed, restart your system to apply the variable changes.
v. Open up a Command prompt and run this command to verify Terraform is installed successfully:
Verify if the Right Version of Terraform Is Installed
Just like below:
How to Install Terraform on Linux
Hither I am taking an example of installing on Ubuntu xx.04 to demonstrate the Linux installation. There are two paths to install on Linux. We'll get through each path beneath.
Installation Using Package Repositories on Linux (Ubuntu)
First, I will go through the steps to install Terraform using the Linux package repository. Follow these steps for Ubuntu. For other Linux versions steps are like and will depend on the specific package repositories. Log in to the system and run these steps as root for sudo access:
1. Make certain the organisation is up-to-date and install these packages which are needed for further steps:
sudo apt-get update && sudo apt-go install -y gnupg software-properties-common curl ii. Next add the Hashicorp GPG key needed past the repository:
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - 3. And so, add the official repository for HashiCorp for Linux:
sudo apt-add-repository "deb [curvation=amd64] https://apt.releases.hashicorp.com $( lsb_release -cs ) main" 4. Now that nosotros have added the repo to the list, permit's update to add together the relevant repository content:
5. Once update, run this command to install Terraform:
sudo apt-get install terraform That should complete the installation. To verify the installation, run this and verify the output:
To verify the version installed, run: terraform –version
Install Using Package repositories on Linux
Adjacent, nosotros volition see the method for installing Terraform using the downloaded zip file. Log in to the system and run these commands equally root:
ane. Before starting the installation, get the download link from the Terraform website. Navigate to https://www.terraform.io/downloads.html and movement to the specific OS version. Here nosotros are looking for Linux:
2. Copy the link for the corresponding download:
three. Now, log in to the Ubuntu system. Make sure Wget and Unzip are installed. If not, install the same:
sudo apt-get install wget unzip 4. Download the Terraform aught file by running the following control. Put the URL copied earlier in the command for download:
wget https://releases.hashicorp.com/terraform/i.1.0/terraform_1.1.0_linux_amd64.zip v. The zip file should download:
6. Unzip the zip file in the current folder:
unzip terraform_1.1.0_linux_amd64.zip 7. The Terraform executable should get unzipped in the current binder:
eight. Move the Terraform executable file to /usr/bin folder:
sudo mv terraform /usr/local/bin/ ix. That should complete the Terraform installation. Verify the installation by verifying the version:
How to Install Terraform on macOS
Next, we volition get through the steps to install Terraform on macOS.
1. Log in to the system and create a folder for the Terraform executable:
sudo mkdir -p /opt/terraform two. Navigate to the new binder:
3. From the Terraform downloads website, re-create the macOS Terraform null file download link:
4. Download the zip file in the previously created folder:
sudo gyre -O < copied_url > 5. Unzip the Terraform files in the electric current folder:
sudo unzip <zip_file_name> The unzipped files will be in the current folder.
6. Add Terraform to the PATH. Navigate to the habitation folder and execute this command to open and edit the bash profile:
Add these two lines on the opened file:
PATH = "/opt/terraform: ${ PATH } " export PATH vii. Execute the file for the path changes to go into effect:
8. Now that Terraform is installed, verify the Terraform version by running
This should bear witness the Terraform version which is installed in the system.
That completes your installation of Terraform on Mac OS.
Adjacent pace? Import existing infrastructure into Terraform. See more than here: How to Import Existing Infrastructure into Terraform (Tutorial with Examples)
Key Points
Terraform allows yous to convert a whole cloud infrastructure to config or lawmaking files. These files can be used to spin upward the entire infrastructure apace and easily. It is an open source tool by Hashicorp. Anyone tin can use it to manage a cloud infrastructure on any of the deject providers.
In this post, nosotros went through the steps to install Terraform on Windows, Linux, as well as macOS. I hope this helps you with your installations. And if you're interested in how to upgrade Terraform to the latest version, encounter: Upgrading Terraform to the Latest Version
Source: https://spacelift.io/blog/how-to-install-terraform
Posted by: scottsturaccou.blogspot.com

0 Response to "How To Install Terraform On Windows"
Post a Comment