What is Terraform?

This lesson will address what Terraform is and how it works.

We'll cover the following


Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Essentially, it takes the infrastructure that you have defined in code and makes it real. The beauty of Terraform is that it does not ask you how to get from the infrastructure you have to the infrastructure you want. It simply asks you what you want the world to look like and then does the hard work.


How Terraform works

Don’t worry if you are not very familiar with writing code. The code that you have to write to configure Terraform is quite different from normal imperative code in languages like Java or C#. You can forget about classes and interfaces etc. Instead, we can think of the code as small blocks that represent something in the real world and a set of properties to configure that resource.

Work with Terraform using blocks.

For example, if we create a block representing an AWS EC2 instance, we can set the properties to say the type of instance and the AMI image we want. We do not need to tell Terraform how to do what we want or how to get from what you have now to what you want as we would in an imperative language. All we have to do is tell Terraform what we want, and that’s it.

Let’s walk through a small example.


This property may seem trivial in this example, but think about the power it gives you when you extrapolate Terraform’s potential over a whole environment.

Now that we know what Terraform is, let’s discuss some of the common problems that occur when you manage your infrastructure by hand instead of using Terraform.