Installing Terraform is not a difficult task, but sometimes it is a little complex when you are working on a particular requirement and you need to customize Terraform to the depth of its limit.
Terraform is a popular infrastructure as a code tool that allows you to manage your infrastructure in a declarative way. With Terraform, you can create, modify, and destroy your infrastructure using simple and concise code. This makes it easy to manage and scale your applications, as you can define your infrastructure as code and track changes over time.
If you’re running Ubuntu, you may be wondering how to install Terraform on your system. There are two main methods for installing Terraform on Ubuntu: using the package manager or downloading the binary files manually. Each method has its advantages and disadvantages, and the choice will depend on your preferences and requirements. In this technical blog, we’ll guide you through the steps of installing Terraform on Ubuntu using both methods. We’ll start with the package manager method, which is the easiest and most convenient way of installing Terraform. Then, we’ll move on to the manual binary download method, which provides more control over the installation process and allows you to install the latest version of Terraform. By the end of this blog, you’ll have a good understanding of how to install Terraform on Ubuntu using both methods.
Whether you’re a beginner or an advanced user, this guide will help you get started with Terraform and manage your infrastructure efficiently.
In this article, I will share the steps to quickly install Terraform on your Linux machine. We will take Ubuntu as an operating system, for CentOS installation instructions please click here.
Terraform installation method
There are two ways to install Terraform in Ubuntu.
- Using Package Manager
- Manual Installation
Using Package Manager
- Download the GPG Key and add into you system for Terraform repository
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
- Add the GPG key into your system.
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
- Install Terraform
$ sudo apt update && sudo apt install terraform
Manual Installation
For Manual installation, you need to follow the below steps
- Download the binary from this https://developer.hashicorp.com/terraform/install
wget https://releases.hashicorp.com/terraform/1.7.4/terraform_1.7.4_linux_amd64.zip
- Unzip the downloaded zip file
unzip terraform_1.7.4_linux_amd64.zip
- change the permission of the file and move it to the bin directory
chmod +x terraform && mv terraform /usr/bin
terraform -v
Conclusion
The package manager method is great for beginners or those who are looking for a quick and easy installation process. By using this method, you can download and install Terraform with just a few commands in your terminal. The package manager will take care of all the dependencies and ensure that Terraform is installed correctly. However, the downside of this method is that you may not always have the latest version of Terraform. The package manager may take some time to update its repository, which means that you may be working with an older version of Terraform. This may not be a significant issue for some people, but it’s something to keep in mind if you need the latest features and bug fixes. The manual binary download method provides more control over the installation process, which is great for advanced users or those who need the latest version of Terraform. By downloading the binary files manually, you can ensure that you have the latest version of Terraform installed on your system. This method also allows you to install Terraform in a custom location, which can be useful if you need to manage multiple versions of Terraform. However, the downside of this method is that it may require more effort, especially if you’re not familiar with the command line interface. You’ll need to download the binary files from the official Terraform website, extract them, and move them to the appropriate location on your system. This can be a bit tricky for beginners, but there are plenty of resources available online that can help you with the process. Regardless of the method you choose, Terraform is a powerful tool that can help you manage your infrastructure efficiently. With Terraform, you can create, modify, and destroy your infrastructure as code, which makes it easy to manage and scale your applications. Whether you’re a beginner or an advanced user, Terraform is a must-have tool in your toolbox.
Pingback: Deploy Azure Landing Zone Azure CAF with Terraform | Step-by-Step Guide
This is really useful