1 Getting Started with Terraform

 

This chapter covers:

  • Why Terraform is so great
  • Syntax of the HashiCorp Configuration Language (HCL)
  • Fundamental elements and building blocks of Terraform
  • Setting up a Terraform workspace
  • Configuring and deploying an Ubuntu virtual machine on AWS

“What does Terraform do?”, is a question I get asked frequently, but it’s not one that I ever find easy to answer. At first, it seems like a no-brainer that should be obvious, but you’d be surprised how difficult it is to describe what Terraform is to someone who’s never used it. When I was first asked this question, I replied that “Terraform is an Infrastructure as Code provisioning tool”, because I knew that’s what I was supposed to say, but I also didn’t necessarily understand what any of that meant. While the phrase adequately describes what Terraform is, it’s also not helpful for understanding what Terraform actually does. HashiCorp, the company behind Terraform, describes the technology as: “a tool for building, changing, and versioning infrastructure safely and efficiently”, but even that isn’t exactly clear. For starters, what does “infrastructure” mean? And what kind of problems can you actually solve with Terraform?

1.1       What makes Terraform so great?

1.1.1   Provisioning Tool

1.1.2   Easy to Use

1.1.3   Free and Open-Source Software

1.1.4   It’s Declarative!

1.1.5   Cloud Agnostic

1.1.6   Richly Expressive and Highly Extendable

1.2       Hello Terraform!

1.2.1   Writing the Terraform Configuration Files

1.2.2   Configuring the AWS Provider

1.2.3   Initializing Terraform

1.2.4   Deploying the EC2 Instance

1.2.5   Destroying the EC2 Instance

1.3       A Brave New Hello World!

1.3.1   Modifying the Terraform Configuration Files

1.3.3   Destroying Infrastructure

1.4       Overview

1.5       Summary

sitemap