In this post, I’m going to show you how to install Terraform, a tool for building, changing, and versioning infrastructure safely and efficiently.

Terraform enables predictable and consistent provisioning of IBM Cloud platform, classic infrastructure, and VPC infrastructure resources by using a high-level scripting language while enabling Infrastructure as Code

During your journey to the cloud, Terraform will greatly help you manage your IT resources and assist in building cloud native infrastructure by offering Infrastructure as Code. Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your data center to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

To learn more about Infrastructure as code, see the following video:

How to install Terraform on a Linux Virtual Server Instance in IBM Cloud

The installation has four main components:

  1. Install the Terraform executable
  2. Install the IBM Cloud Plugin
  3. Install the IBM Cloud Command Line Interface (or CLI)
  4. Install the IBM Cloud CLI VPC Plugin

Prerequisite

Create a Linux Virtual Server Instance (VSI) to use as our system that we want to install Terraform. The advantage of using the VSI as your system to perform Terraform work is that you do not need to install products onto your local machine. Moreover, you can share the VSI with peers who need to do Terraform work without forcing them to install Terraform on their local machines. Lastly, the VSI we will create will cost pennies a day to own in IBM Cloud.

  1. Log into your IBM Cloud account and provision a new VSI with the following specifications:
    • Balanced Profile with 2vCPUs and 4GB RAM
    • Centos 7.x Operating System
  2. SSH into the VSI to begin installing Terraform as guided below. If you are using Windows, you can use a great freeware program called Putty.

Note: We will install Terraform version 0.11.14 and the IBM Cloud Plugin version 0.17.3 because those are the versions as of this writing.

Step 1: Install Terraform

  1. Create the directory with the following command: mkdir terraform && cd terraform
  2. Then, download Terraform using this command: wget https://releases.hashicorp.com/terraform/0.11.14/terraform_0.11.14_linux_amd64.zip
  3. Install a program called ‘unzip’ in order to unpack the download by entering the following: Sudo yum install unzip
  4. Once installed, unpack the Terraform download: unzip terraform_0.11.14_linux_amd64.zip
  5. Set the Linux path to point to Terraform with the following command: export PATH=$PATH:$HOME/terraform
  6. Test that Terraform is installed by typing this command: terraform

Step 2: Install IBM Cloud Plugin v0.17.3

  1. Download the IBM Cloud Plugin v0.17.3 for Linux: wget https://github.com/IBM-Cloud/terraform-provider-ibm/releases/download/v0.17.3/linux_amd64.zip
  2. Unpack the download: unzip linux_amd64.zip
  3. Create a hidden directory for the IBM Cloud Plugin: mkdir -p $HOME/.terraform.d/plugins
  4. Move the IBM Cloud Plugin to that new hidden directory: mv terraform-provider-ibm* $HOME/.terraform.d/plugins/
  5. Move to that hidden directory and run the IBM Cloud Plugin to be sure it is installed: cd $HOME/.terraform.d/plugins && ./terraform-provider-ibm_v0.17.3

Step 3: Install IBM Cloud Command Line Interface (CLI)

  1. Use the following command to install the IBM Cloud CLI: curl -fsSL https://clis.cloud.ibm.com/install/linux | sh

Step 4: Install IBM Cloud Plugin

  1. Run the following command to install the IBM Cloud Plugin: ibmcloud plugin install vpc-infrastructure
  2. Set the IBM Cloud Plugin to use our IBM Cloud Account by giving it your API Key: ibmcloud login --apikey <your key>
    • Note: To create an API Key, go to the IBM Cloud account and choose Manage > Access(IAM) and click the Create an IBM Cloud API Key button.
  3. Set the IBM Cloud Plugin to use either Gen1 or Gen2 of IBM Cloud VPC: ibmcloud is target --gen 1 OR ibmcloud is target --gen 2

Learn more

To learn how to use Terraform, please visit the IBM Demos site on Virtual Private Cloud (VPC) on IBM Cloud for videos and product tours.

To install Terraform on a different Operating System, please follow the links below for each step.

Categories

More from Cloud

IBM Cloud VMware as a Service introduces multitenant as a new, cost-efficient consumption model

4 min read - Businesses often struggle with ongoing operational needs like monitoring, patching and maintenance of their VMware infrastructure or the added concerns over capacity management. At the same time, cost efficiency and control are very important. Not all workloads have identical needs and different business applications have variable requirements. For example, production applications and regulated workloads may require strong isolation, but development/testing, training environments, disaster recovery sites or other applications may have lower availability requirements or they can be ephemeral in nature,…

IBM accelerates enterprise AI for clients with new capabilities on IBM Z

5 min read - Today, we are excited to unveil a new suite of AI offerings for IBM Z that are designed to help clients improve business outcomes by speeding the implementation of enterprise AI on IBM Z across a wide variety of use cases and industries. We are bringing artificial intelligence (AI) to emerging use cases that our clients (like Swiss insurance provider La Mobilière) have begun exploring, such as enhancing the accuracy of insurance policy recommendations, increasing the accuracy and timeliness of…

IBM NS1 Connect: How IBM is delivering network connectivity with premium DNS offerings

4 min read - For most enterprises, how their users access applications and data is an essential part of doing business, and how they service those application and data responses has a direct correlation to revenue generation.    According to We Are Social’s Digital 2023 Global Overview Report, there are 5.19 billion people around the world using the internet in 2023. There’s an imperative need for businesses to trust their networks to deliver meaningful content to address customer needs.  So how responsive is the…

Kubernetes version 1.28 now available in IBM Cloud Kubernetes Service

2 min read - We are excited to announce the availability of Kubernetes version 1.28 for your clusters that are running in IBM Cloud Kubernetes Service. This is our 23rd release of Kubernetes. With our Kubernetes service, you can easily upgrade your clusters without the need for deep Kubernetes knowledge. When you deploy new clusters, the default Kubernetes version remains 1.27 (soon to be 1.28); you can also choose to immediately deploy version 1.28. Learn more about deploying clusters here. Kubernetes version 1.28 In…