Terraform Associate
Deep Dive
IaC fundamentals: what it is, its two main approaches, advantages over manual management, and key differences between tools in the ecosystem.
Contents
Infrastructure as Code (IaC) is the practice of defining, provisioning, and managing IT infrastructure through machine-readable configuration files, instead of manual processes or graphical interfaces.
Infrastructure code is treated the same as application code: it's versioned in Git, reviewed in Pull Requests, tested, and deployed in an automated way.
Without IaC (manual management)
With IaC (Terraform)
There are two approaches to defining infrastructure as code. Terraform uses the declarative approach.
| Characteristic | Declarative | Imperative |
|---|---|---|
| What do you describe? | The DESIRED state ("I want 3 VMs") | The steps to execute ("create VM, configure, start") |
| Who calculates it? | Terraform automatically calculates the diff with plan | You define each step explicitly |
| Idempotency | Native — running it twice = same result | You must program it manually |
| Language | HCL (Terraform), YAML (K8s, CF) | Python, Bash, Go, DSL (Ansible) |
| Examples | Terraform, CloudFormation, Pulumi | Ansible, Chef, Puppet, Bash scripts |
💡 A real-world analogy
Declarative: You tell a chef "I want a Margherita pizza" — they decide how to make it.
Imperative: You tell the chef exactly: "preheat the oven to 220°C, roll out the dough, add sauce, add cheese, bake for 12 minutes..."
Versioning
Every change lives in Git. You can see who changed what, when, and why (PR description).
Reproducibility
Clone the repo, run apply, and get exactly the same infrastructure in any account/region.
Idempotency
Running apply multiple times produces the same result. If it already exists, Terraform doesn't recreate it.
Collaboration
Multiple people working on the same infra with Pull Requests, code review, and CI/CD.
Speed
Spin up a complex environment (VPC, subnets, VMs, DBs, load balancers) in minutes, not days.
Living documentation
The HCL code is the most up-to-date documentation of your infrastructure.
| Tool | Approach | Cloud | Main use case |
|---|---|---|---|
| Terraform | Declarative | Multi-cloud | Cloud/on-prem infrastructure provisioning |
| AWS CloudFormation | Declarative | AWS only | Native AWS infra for AWS-only teams |
| Azure Bicep / ARM | Declarative | Azure only | Native Azure infra |
| Google Deployment Mgr | Declarative | GCP only | Native GCP infra |
| Pulumi | Declarative | Multi-cloud | IaC using programming languages (Python, TS) |
| Ansible | Imperative | Multi-cloud | OS and app configuration (not provisioning) |
| Chef / Puppet | Imperative | Multi-cloud | Config management with a server-side agent |
🎯 For the exam
Did you get this topic?
Test what you just learned
A company wants to manage infrastructure on AWS and Azure using the same language and workflow. It also needs changes to be reviewed in Pull Requests before being applied. Which tool is best suited?
Put what you learned to the test with original Terraform Associate exam questions.
Start Terraform Associate mock examUnlimited mock exams with the Pro plan
Log in to track your progress.