Terraform: Revolutionizing Cloud Management - My Personal Journey

Terraform: Revolutionizing Cloud Management - My Personal Journey

Infrastructure as a Code is a cornerstone of the Cloud technology today

I believe that Terraform developed by Hashicorp really has significantly simplified the lives of professionals working both in the cloud and on-premises. I can attest to this from my own experience. I would like to elaborate further;

I recently took a short course by Josh Samuelson on LinkedIn as a compliment to my on-going AWS cloud certification studies and I was really blown away on what Terraform can do to your cloud environment if given the necessary permission and commands. So what you would spend minutes or even hours provisioning from your management console, with a click of a button with Terraform, this can happen in seconds! So just think of resources like instances, load balancers or even auto scaling groups, these are created or destroyed in a heartbeat. Terraform is referred to as IaC or Infrastructure as Code because it allows you to set up resources or infrastructure in the cloud using only code. So what did I exactly learn from Josh. Let’s go through them slowly. Sorry, if you are already a Terraform guru, you need not follow me here.

  1. Ease of set up

    Setting up Terraform may seem daunting for beginners, but with the abundance of online resources, it can be straightforward. There are two main methods: using the command line interface or the Terraform web console. I began with the latter which is the quicker route. Here you are required to create a working environment known as a workspace and add a project which represents the exact task you wish to do on Terraform. It is best to create the project prior to this. Creating a workspace would require one to choose from any of the three workflow options; version control, CLI-driven and API-driven(as seen in the picture below). I chose the version control(GitHub). Next step involves the process of configuring the variables - Environment and Terraform. This is very important as they do the necessary authentication with the cloud service providers Then since AWS was to be the cloud provider of choice for the course, I added the IAM credentials generated earlier. Care should be taken with handling of your secret credentials. There is a provision for this on the setup page. This authenticates the connection to my AWS account with the proper permissions.

  2. Ease of use - Through Github

    Having set up all that is needed to kick off, the next step is to actually use the code available in my GitHub repository. For those already experienced with Terraform, you might expect that I would fire up my Visual Studio Code editor at this point. However, from GitHub, you can actually edit your code and commit changes in a seamless way. So from here, you can do all your resource configurations. All the code for the provision of resources are carried out in the file, main.tf. This is what Terraform looks for as it seeks to carry out your instructions. There could also be other files like output.tf, variables.tf etc.

  3. See what will happen before “run”

    One important ability of Terraform is to show you what it intends to do before you "apply" the changes. This feature, known as the "plan" command, allows you to preview the actions Terraform will take to achieve the desired state of your infrastructure. This helps in identifying any potential issues or unintended changes before they are actually implemented. In the picture below, the plan shows that there are 22 resources to be created(in green) and 21 to be destroyed(in red). A close look illustrates that load balancers and auto scaling groups are involved, highlighting the dynamic nature of Terraform in managing complex infrastructure components efficiently.

  4. Terraform has a huge library of providers and modules

    As expected, Terraform has made it very easy for developers and architects to speed up the process of resource provisioning. It offers a vast library of resources that cover all the major cloud providers available today. This is accessible via the Terraform registry. As seen in the picture below, more than 4000 providers are represented and these include all the major cloud platforms like AWS, Azure, GCP, Oracle etc. Other services like Kubernetes, Salesforce, VMWare and Vault are also supported.

    Terraform modules enables the use of templates in your codebase. It is packaged code which refers to a particular resource configuration. In the picture below, we see a module for AWS S3. A module has readme, inputs, outputs, dependencies and resources parts.

  5. Wrapping up

    This is just scratching the surface when it comes to employing Terraform for resource provisioning. I decided to document it as part of my learning journey. Moving forward, I plan to use Terraform via the CLI, utilizing the Visual Studio Code editor. I have also tested it on my Linux environment, and it worked well. However, I aim to carry out more advanced work from my Windows CLI environment to gain a deeper understanding of this tool. I will be sharing what I learn here as well.

    Thank you for following.