Understanding Terraform Architecture
At its core, Terraform is a simple command-line program that evaluates source code, which describes what a desired state should look like, compares it against what the actual state is, constructs a plan to transform the actual state into the desired state, and can execute the plan. But don’t let its perceived simplicity fool you. Terraform’s internal complexity manifests itself in its external simplicity.
Terraform is a large, source-available project written in Go that maintains the command-line executable. It provides baseline functionality such as HashiCorp Configuration Language (HCL) parsing, state management, plan creation, and execution.
Terraform is extremely powerful, yet ironically, it does very little by itself. But here’s the exciting part: Terraform’s superpower comes from its extensibility, a power that is not limited to its creators. The actual Terraform executable, by itself, can’t do much, but when bundled with one of its plugins—called providers—Terraform can do quite a lot! This extensibility is a testament to the collaborative nature of the Terraform community, where everyone can contribute to its growth and capabilities.
In this chapter, we will cover the following topics:
- Understanding Terraform architecture
- Understanding Terraform state
- Understanding how to build and consume modules
- Understanding how to use the command-line interface (CLI) effectively
Terraform has four superpowers that distinguish it from other tools: planning, extensibility, configuration language, and modularity. Some tools may share some of these, but they don’t have them all. With these powers combined, Terraform is a game changer in cloud automation.