5 Important Reasons To Learn Terraform Before Cloud Computing.
Tags: cloud, devops, aws
Published: 2019-10-10 18:34:44

---
title: 5 Important Reasons To Learn Terraform Before Cloud Computing.
published: true
date: 2019-10-10 18:11:18 UTC
tags: Cloud, DevOps, AWS
cover_image: https://www.terraform.io/assets/images/og-image-large-e60c82fe.png
canonical_url: https://www.thedevcoach.co.uk/learn-terraform-before-cloud-computing/
---

Ever wanted to learn Kubernetes? Serverless? Write some Microservices in AWS or GCP? Awesome… But don’t. Or at least, not yet. Why? Because the first thing you should learn is Terraform. Don’t touch Serverless. Definitely don’t touch Kubernetes, and I’d probably not even bother creating an AWS S3 bucket.

![Terraform](https://i0.wp.com/www.thedevcoach.co.uk/wp-content/uploads/2019/10/terraform.png?fit=520%2C313&ssl=1)

There are many reasons for you to be excited to learn Cloud Engineering as a whole. But no other decision impacted my ability to learn Cloud Engineering than: first learning Infrastructure As Code. In hindsight, I wish I did it sooner.

In todays article I’ll try (and hopefully successfully) to convince you why Infrastructure As Code is the most logical starting point for learning Cloud Engineering concepts and tools.

**By the end of the article you’ll know what Infrastructure As Code (with Terraform) is and I’ll give you 5 reasons why Terraform should be your starting skill when learning Cloud Engineering.**

## What is Infrastructure As Code (And Terraform)?

First of all, [Infrastructure As Code](https://www.thedevcoach.co.uk/infrastructure-as-code-ultimate-guide/) is the practice of writing your infrastructure i.e web servers, load balancers, databases through version controlled scripts (read: code). There are many generic [advantages to Infrastructure As Code](https://www.thedevcoach.co.uk/infrastructure-as-code/). But today I want to talk specifically about why Infrastructure As Code is a logical first step prior to learning Cloud Engineering.

And what is Terraform? Terraform is a third party tool that allows us to write the aforementioned Infrastructure As Code, but we’ll talk a little more about why Terraform kicks ass later.

Importantly though, Terraform is a [declarative Infrastructure As Code tool](http://declarative), which means that creating, updating and deleting resources is easy with Terraform. These workflows (create, update and delete) are are a first class concept in Terraform, unlike other Infrastructure As Code methods such as ad-hoc scripting (i.e with the [AWS SDK](https://aws.amazon.com/tools/)). Don’t worry too much about what declarative Infrastructure As Code means, we’ll cover it in more detail soon enough.

If you want to know more about these concepts, I’d suggest you check out: [Infrastructure As Code: A Quick And Simple Explanation.,](https://www.thedevcoach.co.uk/infrastructure-as-code/) [Declarative vs. Imperative Infrastructure As Code](https://www.thedevcoach.co.uk/declarative-vs-imperative-infra/) and [Learn The 6 Fundamentals Of Terraform — In Less Than 20 Minutes.](https://www.thedevcoach.co.uk/the-six-fundamentals-of-terraform/)

## Infrastructure: Is It So Hard?

So now we know what Infrastructure As Code is, how can it help us learn Cloud Engineering? Let’s start with a Tweet that I recently saw from Cory House ([@housecor](https://twitter.com/housecor)).

{% twitter 1180841911562702850 %}

{% twitter 1180844147080601601 %}

Firstly I should say that I really like Cory, and his work — but on this topic I think Cory is wrong. “DevOps” may have slow feedback loops in ways that are too big to discuss today. But I don’t think “DevOps” is inherently slower than other types of engineering, you just need the right setup. And I think by using Terraform you can get a correct setup that makes feedback loops fast, and ultimately makes your learning quicker.

So — without further ado — let’s discuss the five reasons Infrastructure As Code should be your first step to learning Cloud Engineering.

## Reason 1: Faster Feedback Loops With Terraform Plan

![Terraform Plan](https://developer.hpe.com/uploads/media/2019/4/123-1555102758367.png)

As Cory said, when it comes to learning or implementing technology it’s important that we can experiment easily. We want to be able to update code and instantly see the results of what we did, so that we know whether we’re right, or wrong and where we need to course correct.

And in the web development world, we get fast feedback through techniques such as TDD. We write the test first, leave it running and then write the code to match the tests. Tests help us work through our problems piece-by-piece, ensuring that we haven’t broken anything along the way. And an iterative approach can take away some serious headaches.

When you write your infrastructure-as-code with Terraform, you’re going through the same TDD loop. Except, in Terraform, we execute the feedback loop by running a command called `terraform plan`. A Terraform plan is a dry-run command that outputs a so called “execution plan”. An execution plan simply tells you what is going to happen when you run your Infrastructure As Code script. What will be destroyed? What will be created? Or what will be updated?

If you know your target state, similar to a test in TDD, you can easily tinker with your Terraform code until the `terraform plan` returns as you expected. If you missed required fields, Terraform will tell you, if you made a syntax error, Terraform will tell you. All of these bits of early feedback contribute to the fast feedback loops that help reduce the friction and frustration of learning.

When we contrast the speed and repeatability of running Terraform and Infrastructure As Code versus poking around in interfaces making changes manually… Terraform wins. Hands down.

## Reason 2: Easy Roll Back

 ![Versioned Terraform State Files](https://i0.wp.com/www.thedevcoach.co.uk/wp-content/uploads/2019/10/Screenshot-2019-10-08-at-07.36.15.png?resize=760%2C75&ssl=1)

The next reason that Infrastructure As Code helps you to learn Cloud Engineering is through easy rollbacks.

When your code is written entirely in version control, you can easily step forward or backwards through changes. Let’s say you accidentally created a resource you didn’t mean to, simply delete the resource and re-run Terraform. Terraform will then destroy that resource for you. As long as you’re committing frequently you’re going to always have a history of changes that you can easily rollback to.

Compare automated Infrastructure As Code rollbacks with Terraform against trying to rollback changes manually by hand and… Yeah. Rolling back manually configured changes can be a nightmare. And we really want to avoid nightmares when we’re learning.

## Reason 3: Less Worry About Cost

One big cause of stress for me when I learn cloud engineering is cost. I’ve even been burnt badly and had an $3000 dollar bill due to my own negligence. Ouch.

 ![A $3000 AWS Bill](https://i0.wp.com/www.thedevcoach.co.uk/wp-content/uploads/2019/07/Screenshot-2019-07-24-at-17.16.40.png?resize=760%2C286&ssl=1)

I got this particular bill because I misconfigured the AWS account I was working on. The misconfiguration [lead to my account getting hacked](https://www.thedevcoach.co.uk/how-to-setup-an-aws-to-experiment-and-learn/). Resources were created that didn’t belong to me, leading to a huge bill, and a serious pain-in-the-ass. If I had written my infrastructure properly (as code) in the first place the issue likely wouldn’t have come about. Writing Infrastructure by hand leaves you vulnerable to these types of threats. You don’t want a heart-attack-inducing-email bill like this, trust me.

Secondly, when your code is in [Infrastructure As Code](https://www.thedevcoach.co.uk/infrastructure-as-code-ultimate-guide/) you can easily tear down all the resources that you’ve created, you have a reference to them after all. Also, remember that before I mentioned [Terraform being declarative](https://www.thedevcoach.co.uk/declarative-vs-imperative-infra/)? Declarative Infrastructure As Code you simply declare the end state and Terraform works out how to get you there. In this case, the end state is: No state. Delete everything. And because Terraform’s state file tracks all our resources we can easily declare that we want to delete everything. All we need to do is run `terraform destroy`.

Again, as compared with frantically clicking through AWS trying to find resources to kill, running a simple command to tear down all your resources is a no-brainer. Notice the service you spun up is costing more than you expected? Kill it. Easy.

## Reason 4: Working Across Clouds

![Image result for aws gcp](https://i0.wp.com/miro.medium.com/max/3222/1*go7sTFOGN2fJGgYrI3E-FA.png?w=760&ssl=1)

And now onto a point specifically about Terraform, rather than Infrastructure As Code as a whole. A big draw for working with Terraform is that it’s a third-party tool. Unlike other tools like [CloudFormation](https://aws.amazon.com/cloudformation/), which are heavily coupled to a cloud provider (in this case, [AWS](http://aws.amazon.com)).

Because of the way Terraform is written, it has a core library which is extended by use of a feature called [Providers](https://www.terraform.io/docs/providers/index.html). A provider is essentially a third-party plugin that allows you to use Terraform with a new, or any tool. Terraform has providers for [GCP](https://cloud.google.com), Azure, [AWS](https://aws.amazon.com) and also other cloud tools you might not think about, like [Auth0](http://auth0.com), [Stripe](http://stripe.com/). Anyone can (and they do!) write a new Provider and share it with the Terraform community. Which means you’re not stuck working with only one Cloud Provider.

And another big advantage to the third-party tooling of Terraform is that once you learn the technology once, it works seamlessly with the other cloud providers, such as [GCP](https://cloud.google.com). So if you suddenly decide you want/need to start learning GCP, you don’t need to re-learn Infrastructure As Code tooling.

Poking around provisioning Cloud resources via an interface quickly makes you dependent on the interface. Learn how to script resources by Infrastructure As Code and you increase the mobility of your skills between Cloud services. Win.

## Reason 5: Out of the box modules

 ![The Terraform Registry](https://i0.wp.com/www.thedevcoach.co.uk/wp-content/uploads/2019/10/Screenshot-2019-10-08-at-07.55.13.png?resize=760%2C514&ssl=1)

And last but not least, another reason to use Terraform to learn cloud is: Re-using Modules. If you’re not up-to-speed on what a Terraform module is, I’d suggest this article on: [Terraform Modules: A Guide To Maintainable Infrastructure As Code.](https://www.thedevcoach.co.uk/terraform-modules-tutorial/)

But the short definition is: A Terraform module encapsulates related infrastructure into a neat, re-usable and shareable component. Modules can be used to reduce repeated code in your own Infrastructure As Code. But, importantly for us, we can leverage modules that have been created by the community! Using Terraform Modules can drastically reduce the amount of time it takes to get up and running playing with a new cloud tool.

## So You’re Gonna Learn Terraform, Right?

Hopefully I did a decent job of convincing you why Infrastructure As Code, or more specifically: Terraform makes sense to learn before you learn Cloud Engineering. I know that in your haste you just want to dive in, but if you take this (brief, I promise!) step by you’ll drastically reduce the headaches you experience when wrestling with manually created Infrastructure.

If I did convince you, and you do want to get started right away I wrote an opinionated, step-by-step guide on how you can bootstrap an AWS account with Terraform (and a versioned backend) so you can start experimenting. To get your hands on the resource, all you have to do is sign up to the [Cloud Native Software Engineering Newsletter](/newsletter).

Learning Cloud Engineering is super fun, and I want to see more engineers getting involved, and I think getting literate with Infrastructure As Code is the best way to do it. Dive in, and let me know how you get on!

---

The post [5 Important Reasons To Learn Terraform Before Cloud Computing.](https://www.thedevcoach.co.uk/learn-terraform-before-cloud-computing/) appeared first on [The Dev Coach](https://www.thedevcoach.co.uk).

Lou is the editor of [The Cloud Native Software Engineering Newsletter](https://thedevcoach.co.uk/newsletter) a Newsletter dedicated to making Cloud Software Engineering easier, and keeping you up-to-date.