Terraformer: A Game-Changer for Cloud Infrastructure

Written by Muhammad Hunain

Cloud Engineering Manager

The textbook definition of Terraformer is that it is a CLI (Command Line Interface) tool to generate files from existing infrastructure. In short, it is Reverse Terraform that involves creating Terraform files from pre-existing infrastructure. Many industries face the challenge of integrating their existing infrastructure to Terraform script. The typical cloud infrastructure environment is highly complex, including VMs, storage buckets, PaaS resources, etc., already set in complex distributed architectures. While terraform has a function known as Terraform Import, the resource drain in manually configuring it is too expensive to pay in terms of both time and cost. And few teams have the privilege of starting from scratch when they wish to transition to Infrastructure as Code. It is this challenge of integrating existing resources in a timely and cost-effective manner that Terraformer seeks to redress.

With Terraformer, there are three simple steps:

  • Install
  • Set it up. When it comes to setting up Google Cloud, to access your information from your Google Project, you provide authentication information by setting up the environment variable “Google_Application_Credentials” along with the file path to the JSON file that contains your service account key.
  • You will now be able to set up Terraformer state files which will already have the infrastructure registered.

An additional feature of Terraformer is that it requires only read-only permissions to list service resources, thus ensuring that it does not change anything within the existing infrastructure. This feature makes it an extremely secure option for the automation of your cloud environment.

Terraformer vs Terraform Import

In Terraform Import, first, you will define the resource block in the terraform configuration file with complete resource metadata. Then you will use the Terraform Import command with resource block name & the entire path to the provider resource such as the projectid, region & instanceid. Once you have entered all the essential details, terraform import will check for the specified resource and register it in the state config file.

example:

terraform import google_compute_instance.default projects/{{project}}/zones/{{zone}}/instances/{{name}}

This import command has to be applied manually for all the resources that belong to a GCP project after creating subsequent recourse blocks in the terraform configuration file.

With Terraformer, this manual process becomes automatic. Once you configure Terraformer with correct read permissions and run the Terraformer import command, it generates all the relevant terraform scripts for your existing infrastructure. Not only that, but it also registers the current state of the infrastructure with the desired state in the terraform state files, and hence it becomes synced with your cloud environment. Thus, we do not have to import any resources manually.

example:

terraformer import google --resources=gcs,forwardingRules,httpHealthChecks,firewall,instances,networks,subnetworks --connect=true --regions=us-central1 --projects=xyz-123

Once you input the provider, you can download the dependencies. You then have an identical terraform script to match with the infrastructure. With the help of Terraformer, Infrastructure as Code is more fluent and automatic than ever before! And all in a matter of minutes!

To learn more about how quickly Terraformer performs this task compared to Terraform import, check out our demo with our cloud expert.

What Terraformer Means for GCP?

Terraform is a tool developed by Waze, a subsidiary of Google. However, it is not an official Google product and is an open-source tool that can be modified and used across all major platforms such as AWS, Azure, GCP, IBM Cloud, and AliCloud.

BigQuery, Cloud Functions, CloudSQL, DataProc, and GKE are some of the primary supported GCP services on Terraformer. As mentioned earlier, with Terraformer, converting existing infrastructure into Terraform files has been made much easier, but what does that mean for businesses exactly? The benefits of Terraformer for enterprises include the fact that now when setting up their infrastructure on the cloud, they can do save in three major areas: cost, speed, and risk.

  • Cost: With Terraformer, teams can now spend less time migrating existing infrastructure to their cloud environment, which leaves more time for more critical enterprise tasks. In short, focus on outcomes over process. This helps reduce costs significantly.

  • Time: The automation of the infrastructure converting to Terraform script is much faster, allowing for faster execution when configuring your infrastructure and allowing other teams to work more efficiently.

  • Risk: Terraform import requires a lot of manual work, leading to a higher chance of malfunctioning due to human error. With less manual work involved, there is higher reliability and a reduction in downtime.

Terraformer In Practice: Royal Cyber Case Study

Royal Cyber team leveraged Terraformer to aid a Fortune 500 company in the field of truck manufacturing to provision their production in their Google Cloud environment.

The customer recently migrated their managed APIs from IBM API connect to Apigee GCP. Their entire Dev Environment was also provisioned manually through gcloud commands, including Apigee organization, shared VPC networks, instance groups, SQL servers & load balancers. They wanted to deploy their production environment using the terraform scripts. However, the main challenge was that their production Apigee organization was already up and running along with the shared VPC network.

Given this scenario, we used Terraformer to generate Terraform scripts for their existing production environment while updating the configurations to include the additional missing resources. These updated scripts were then applied to their production environment so that the current state of infrastructure became synced with the desired state in the tfstate files. Hence their entire prod environment achieved IaC automation without destroying, redeploying, or manually importing their existing resources.

You may be interested to know how we helped the client in speeding up their software release cycles.

How Royal Cyber Can Help

At Royal Cyber, as proud partners of Google Cloud, we believe that we have the right team and expertise to harness this tool effectively. As our video demonstrated, we have experts passionate about the latest tools and technologies available in the market. With the help of tools like Terraformer, we aim to implement and create an environment that is best suited towards modernizing your environment and at the same time making high savings.

Connect with us and let us discuss possible collaboration opportunities around Google Cloud. For more information, you can email us at [email protected] or visit www.royalcyber.com.

Leave a Reply