What is Terraform and Why do we need it?

Wikipedia says:-

Terraform
 is an open-source infrastructure as code software tool created by HashiCorp. It enables users to define and provision a datacenter infrastructure using a high-level configuration language known as Hashicorp Configuration Language (HCL), or optionally JSON. Terraform supports a number of cloud infrastructure providers such as Amazon Web Services, IBM Cloud (formerly Bluemix), Google Cloud PlatformDigitalOcean, Linode, Microsoft AzureOracle Cloud InfrastructureOVHScalewayVMware vSphere or Open Telekom Cloud[11] as well as OpenNebula and OpenStack.


Hashicorp says:-

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions.

Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied.

The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc.

Infrastructure as Code (IaC):-

Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used.

Execution Plan:-

Terraform has a "planning" step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure.

Resource Graph:-

Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation:-

Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

Why infrastructure as a code:-

1. Lowers cost 

And it does this by reducing the amount of time required to provisioning and manage infrastructure. And what we mean by this is that one person or, you know, maybe a small team can manage a very, very large infrastructure with a lot of confidence. When you use infrastructure as a code, when you really codeify the configuration that you're using and you have some automated provisioning set up that you don't have to manually going copy things around.

2.Improvement of Speed

And this happens because when you codeify your infrastructure and your provisioning you can do things much faster than you can as a human. One of the older ways of going through in provisioning machines and doing your configuration is maybe you would write a bunch of bash scripts that you would kind of cobble together, but you would have to manually do them one after another. Or you would copy and paste lines from a file that you knew this is the exact thing that you needed to run, but doing it that way is still slower than if you had an automated process where you were able to write your configuration and then have the machine go and run it on a group of nodes simultaneously. So that's much, much faster than you manually doing it.

3. Improves Stability and Security

And we get stability because we can see the changes that are being made. And we know that we're specifying maybe specific versions of packages that were installing and we can have these be peer reviewed and then additionally, we get the security benefits of that, too. So you have if somebody can watch the changes being made to your configuration through your configuration management repositories. So you write your code. Somebody reviews that code. They can see maybe if you have malicious people internally who are trying to add things or back doors and tear infrastructure, those can be found in pure review. And even more than that, you can automate some security checks on your infrastructure, using some of the same tools that we're gonna be talking about. 

So with these goals and benefits in mind, we want to lower costs, improve speed and improve stability and security of our infrastructure with Terraform.

Comments

Popular posts from this blog

Terraform Commands - Hands-on Learning

Terraform Console and Output

Terraform - Tainting and Updating Resources