Setting up Terraform and IBM Cloud Provider on Windows

5 min read

Setting up Terraform and IBM Cloud Provider on Windows

This blog post is a quick guide on how to setup Terraform and IBM Cloud Provider on Windows operating system.

First of all, What is Terraform?

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned. Defines infrastructure as code to increase operator productivity and transparency.

Source: Terraform.io

Source: Terraform.io

The IBM Cloud provider is used to manage IBM Cloud resources. The provider must be configured with the proper credentials before it can be used.

While working on our solution tutorial covering Infrastructure as code, we decided to add steps for setting up Terraform on Windows OS as well.

Setting up Terraform

  1. Download and install Terraform Windows 64-bit.

  2. Copy files from the downloaded zip to C:\terraform (Create terraform folder).

  3. Open the command prompt as an administrator and set the PATH to use terraform binaries.

    set PATH=%PATH%;C:\terraform

Check Terraform installation by running terraform. You should see a list of Common commands.

Setting up Terraform

Setting up IBM Cloud provider

  1. Download the windows 64-bit  IBM Cloud Provider plugin for your system and extract the archive. You should see the terraform-provider-ibm executable file.

  2. On Windows, the file needs to be placed in terraform.d/plugins beneath your user’s “Application Data” directory.Run the below commands on a command prompt Provider Configuration

    MD %USERPROFILE%\AppData\terraform.d\plugins
    MOVE PATH_TO_UNZIPPED_PROVIDER_FILE\terraform-provider-ibm.exe %USERPROFILE%\AppData\terraform.d\plugins

    Note: Replace PATH_TO_UNZIPPED_PROVIDER_FILE with the appropriate path on your machine.

Whenever you create a virtual machine (VM), you will need a public SSH key to access the VM created by the respective configuration. Download, install, launch Git Bash and run the below command to copy the public SSH key to your clipboard

clip < ~/.ssh/id_rsa.pub

The story doesn’t end here. In the tutorial, you will use a sample configuration to provision a Linux virtual server, with Apache web server, MySQL, and PHP server termed as LAMP stack. You will then update the configuration to add an Object Storage service and scale the resources to tune the environment (memory, CPU, and disk size). Finish by deleting all of the resources created by the configuration.

Be the first to hear about news, product updates, and innovation from IBM Cloud