3-Way Multi Cloud Infrastructure Management With Terraform HCL

Kannadasan Palani Apr 19 - 5 min read

Audio : Listen to This Blog.

A Stronger Digital expertise mandates better Data Authority. Data plays a major role in different aspects of our business especially since the rise of Cloud computing technologies. Traditional storage systems are increasingly losing their charm while Cloud Storage infrastructures are being explored and supported more with innovative advances. However, Cloud Infrastructure can easily get too painful too quick if one isn’t rightly equipped for its management. Therefore, it’s imperative that we discuss and understand about Cloud computing technologies, their key service providers and most importantly the right means to manage the Cloud infrastructure.

Peeping Into the Wonders of Cloud computing:

Cloud computing, as it is very well known in recent times, is the delivery of computing services including – servers, storage, databases, networking, software, analytics, and intelligence—over the Internet (“the cloud”). We saw how during the disruptive reality of last two years, cloud provided us with not only business continuity but also faster innovation, flexible resources, and economies of scale. Some of the major ways in which cloud has change the digital landscape for good are:

  • Economy – You Pay only for cloud services that you use,
  • Better ROIs – Lower Op-ex and Cap-ex for even better service quality
  • Automation – Form infrastructure management to regular deployments, everything is more efficient and automation-friendly.
  • High Scalability – As the business grows in terms of clientele, the entire system can easily scale in no-time

It is also a well-known fact that many major players have already established themselves as Cloud Infrastructure experts. Depending on the popularity and business merits of these cloud service providers, their share in the market varies (figure below)

Cloud-Infrastructure-Services

With the varying benefits and service feasibilities of the cloud vendors, business find it more economical to opt for multiple cloud infrastructures and invest in better expertise and resources to manage them all. One important tool that helps in this task is Terraform.

Terraform – HCL and Multi-Cloud Infrastructure Management

Terraform is a popular infrastructure-as-code (IaC) tool from HashiCorp for that helps with building, changing, and managing infrastructure. For managing Multi Cloud environments it uses a configuration language called the HashiCorp Configuration Language (HCL) which codifies cloud APIs into declarative configuration files. The configuration files are then read and provided an execution plan of changes, which can be reviewed, applied, and appropriately provisioned.

To understand this better, we need to dive into the different aspects of Terraforms working that come together to manage our multi-cloud infrastructures.

  1. Terraform Plugins: A provider is a plugin that Terraform uses to create and manage our resources. It interact with cloud platforms and other services via their application programming interfaces (APIs).

We have more than 1,000 providers in the HashiCorp and the Terraform community to manage resources on Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), Kubernetes, Helm, GitHub, Splunk, and DataDog etc. and also we can find providers for many of the platforms and services in the “Terraform Registry”.

  1. Terraform Work flow: Terraform – Workflow consist of 3 stages
    • Write – Define the resources
    • Plan – Preview the changes.
    • Apply – Make the planned changes.

        2.1 Write:  We can define resources across multiple cloud providers and services. For example, we can create a configuration to deploy an application on virtual machines in a Virtual Private Cloud (VPC) network with security groups and a load balancer.

      2.2 Plan:  We can create an execution plan describing the infrastructure it will create, update, or destroy based on the existing infrastructure and our configuration.

     2.3 Apply: Based on our approval, Terraform performs the proposed operations in the correct order, respecting any resource dependencies. For example, if we update the properties of a VPC and change the number of virtual machines in that VPC, Terraform will recreate the VPC before scaling the virtual machines.

Hashicorp Terraform    3. Terraform Cloud Infrastructure Management

      3.1 Installing Terraform (CentOS/RHEL)

Install yum-config-manager to manage your repositories.

sudo yum install -y yum-utils

Applying yum-config-manager to include HashiCorp Linux repo

sudo yum-config-manager –add-repo

https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Install.

sudo yum -y install terraform

    3.2 Building Infrastructure

Configure the AWS CLI from your terminal.

aws configure

Ensuring separate working directories for each Terraform configuration

mkdir learn-terraform-aws-instance

Change into the directory.

cd learn-terraform-aws-instance

Create a file to define your infrastructure.

touch main.tf

Complete configuration – deploy with Terraform

Complete Configuration Terraform

    3.3 Change Infrastructure

Create a directory named learn-terraform-aws-instance and use the above configuration into a file named main.tf.

Initialize the configuration.

$ terraform init

Apply the configuration (the confirmation prompt needs ‘Yes’ as the response to proceed)

$ terraform apply

For updating the ami of your instance the aws_instance.app_server resource needs to be changed under the provider block in main.tf by

Replace the current AMI ID with a new one.

Finally, post-configuration-change, again run terraform apply to see the change on existing resources

   3.4 Destroy Infrastructure

The terraform destroy command terminates resources managed by our Terraform project. Destroy the resources which we created

By this way, we can Build, Change and Destroy Various Cloud infrastructure (AWS, AZURE, GCP etc.) by using Terraform HCL .

Conclusion

Managing a single cloud infrastructure for private and public business purposes can be helpful. It seems humanely impossible to juggle between multiple cloud vendors. Therefore, external help in the form of Terraform is highly valuable for the business to maintain their bandwidth for consistent innovations. The 3-way process to ensure efficient multi-cloud infrastructure management is a gift that would easily make Terraform an essential weapon in our digital arsenal.

 

Leave a Reply