Skip to the content.

Applying Terraform code on Google Cloud Platform

This page describes how to apply the Terraform code for the IESI solution on the Google Cloud Platform (GCP)

Pre-requisites

Assemble the configuration from git

One way to get the Terraform code and apply it is by getting the code from git and assembling it into a workspace. This means that the code is copied to this workspace and a configuration is applied on top of it.

Important The assemble script removes all providers and state information if the option is set to remove the instance.

Get the git repository

First, clone the git repository for iesi.

Create workspace

Now that each repository is fetched, the Terraform code can be assembled in a workspace:

Assemble the Terraform code

Once the workspace folder has been created, the Terraform code can be assembled. Each assembly has an instance for wich a configuration will be applied.

So to move forward, you need to create a folder for the configuration in the [workspace]/conf folder.

Next, the assembly process can be started from the shell script that can be found in the iesi repository at deploy/gcp. Run the assemble.sh script with the following arguments: 1) -w=[path] or –workspace=[path]: workspace folder [mandatory] 2) -i=[instance] or –instance=[instance]: instance name [optional, default: assembly] 3) -c=[configuration] or –configuration=[configuration]: configuration name [optional, default: default] 4) -r or –remove: remove instance [optional, default: no]

After completion, the Terraform code will be assembled to [workspace]/[instance]

Now, you can run Terraform as required to deploy your GCP infrastructure. However, remain careful not to destroy your Terraform state by running the assembly with the remove instance flag. For more information on Terraform state management, have a look here.

As a best practice, you can organize your state management using Terraform backends.