chapter one

1 A brief overview of Terraform

 

This chapter covers

  • Basic Terraform Components
  • Introducing Infrastructure as Code
  • Defining Declarative Languages
  • A brief overview of Graphs
  • The Terraform Deployment Workflow
  • The Relationship between Terraform and OpenTofu

The first time I set up an AWS VPC, which is the system AWS uses to isolate networks from each other, by hand it took me several days. Admittedly I had never done it before so there was some research involved, but even once I’d done it a few times it still took several hours to manually create and configure a VPC that spanned multiple availability zones and had both public and private subnets.

When I first discovered Terraform I attempted to build a VPC again. Instead of creating it manually, I wrote code using the Terraform language to describe my VPC and all of the components that it needed. When I first ran the code it’s not an exaggeration to say I was blown away- Terraform launched over 70 resources needed to create that highly available VPC Structure and it did it in about a minute. From then on whenever I needed a VPC it was a simple matter of reusing that already written code.

1.1 Terraform Overview

1.1.1 Terraform Language

1.1.2 Terraform CLI and Core

1.1.3 Providers

1.1.4 Vendors

1.1.5 Backends

1.1.6 Workspaces

1.2 Infrastructure as Code

1.2.1 Software Development Practices with IaC

1.2.2 Repeatability and Shareability

1.2.3 Continuous Integration and Deployment

1.3 Declarative Languages

1.3.1 Declarative versus Imperative Languages

1.3.2 Dependency Resolution

1.3.3 Pitfalls of Declarative Languages

1.4 Terraform Deployment Flow

1.4.1 Change Desired

1.4.2 Init

1.4.3 Plan

1.4.4 Apply

1.5 What are people using this for?

1.5.1 Machine Learning Training

1.5.2 API and Web Services

1.5.3 SSO Authentication Structure

1.5.4 Rapid Prototyping

1.6 Terraform and OpenTofu

1.6.1 HashiCorp’s History with Open Source

1.6.2 HashiCorp License Changes

1.6.3 Community Reactions

1.6.4 OpenTofu Fork

1.6.5 OpenTofu and Terraform Compatibility

1.6.6 Using OpenTofu

1.7 Summary