Terraform 1st Impression

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Introduction

I am Akshay Rao, joined Annotation.Inc on December 2020.I like technology a lot and reading about them how they help in solving real-life problems. I was going through the DevOps tools like git, Jenkins, Anisble and struck by this terraform tool because of it usability.

What is terraform?

Terraform is open-source tool which can helps devops engineer to provision infrastructure in the service provider's cloud, it is just like Infrastructure as a code (IaaC), but it comes with a lot of other benefits. Now, you may ask we have cloud formation in AWS what is the big deal right? Even I thought the same but by reading about it, got to know its role in the cloud.

Why DevOps engineer use terraform?

Before answering this question let us take a scenario in which Company A is using (Let's say) AWS as it's cloud provider but the customer wants its application to be deployed in the other cloud provider (let's say) google cloud, due to security reasons. Now company should change its cloud provider or hire gcp architect, but solutions are either time consuming or expensive. To solve this problem terraform comes to rescue, it helps in provisioning infrastructure and deploy application in multiple cloud providers without changing your own cloud provider. Is called as Multi-cloud strategy, where organization is uses multiple cloud providers for various benefits like fault tolerance, leveraging services from other cloud providers, avoiding lock-in periods and the most important cost optimization.

Let us look at other advantages as well:-

Open source:  Terraform is backed by large communities of contributors who build plugins to the platform. Regardless of which cloud provider you use, it's easy to find plugins, extensions, and professional support. This also means Terraform evolves quickly, with new benefits and improvements. . added consistently.

Platform agnostic:  Meaning you can use it with any cloud services provider. Most other IaaC tools are designed to work with single cloud provider.

Immutable infrastructure:  Most Infrastructure as Code tools create mutable infrastructure, meaning the infrastructure can change to accommodate changes such as a middleware upgrade or new storage server. The danger with mutable infrastructure is configuration drift — as the changes pile up, the actual provisioning of different servers or other infrastructure elements'drifts' further from the original configuration, making bugs or performance issues difficult to diagnose and correct.

Architecture of the terraform

It has two main components

  1. Core

The core requires of 2 input

  1.  tf.config file:-This is the file in which the engineer writes the code for the infrastructure (what he desires to build / provision) that has to be deployed in declarative language.
  2. State:-The terraform keeps the up to-date state of how the current setup of the infrastructure looks like.

Now the core takes these inputs and figures out the plan what needs to be done, so it compares what is the current state and what is the configuration that you desire. When it finds a difference between the current state and the desired state in config file , it will figure out what needs to be created, updated or deleted in order to reach the desired state.

  1. Providers for specific technologies

These might be AWS or Azure for IaaS for infrastructure level tasks, terraform also provides other platform as a service tools like kubernates and some of Software as a service. It has 100's of providers and they provide terraform access to its resources. Once the core creates. . an execution plan based on the inputs in the config file and current state, then it uses these providers for specific technology execute plan, to connect to those platforms and to carry out those execution steps.

Some commands that can be used in terraform

  1. Refresh-query's infrastructure provider for current state
  2. Plan-creates an execution plan
  3. Apply-execute the plan
  4. Destroy-deletes the resources or infrastructure

Conclusion Conclusion

I think this blog gives you overview of what is terraform, why it is used. If you have any concerns or haven't included a topic in the blog or have mistaken in understanding some concepts please contact me.