chapter one

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

Terraform is a deployment technology for anyone who wants to provision and manage their Infrastructure as Code (IaC). Infrastructure refers primarily to cloud based infrastructure, although anything that could be controlled through an Application Programming Interface (API) technically qualifies as “infrastructure”. Infrastructure as Code is the process of managing and provisioning infrastructure through machine-readable definition files. We use IaC to automate processes that used to be highly manual .

When we talk about provisioning, what we mean is the act of deploying infrastructure, as opposed to configuration management, which deals mostly with application delivery, particularly on virtual machines (VMs). Configuration management (CM) tools like Ansible, Puppet, SaltStack and Chef are extremely popular and have been around for many years. Terraform does not supplant these tools, at least not entirely, because infrastructure provisioning and configuration management are inherently different problems. That being said, Terraform does perform many of the functions once reserved by CM tools, and many companies find they do not need CM tools after adopting 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   Declarative Programming

1.1.5   Cloud Agnostic

1.1.6   Richly Expressive and Highly Extensible

1.2    Hello Terraform!

1.2.1   Writing Terraform Configuration

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    Brave New Hello World!

1.3.1   Modifying Terraform Configuration

1.3.2   Applying Changes

1.3.3   Destroying Infrastructure

1.4    Fireside Chat

1.5    Summary