Terraform Associate
Deep Dive
Why Terraform exists, what problems it solves with its multi-cloud and provider-agnostic approach, and the fundamental role of state in infrastructure management.
Contents
Terraform lets you define, plan, and apply infrastructure changes safely and efficiently, using a high-level configuration language (HCL) that describes the desired state of the infrastructure.
Write
You define resources in HCL: what you want to exist
Plan
Terraform compares the current vs. desired state and shows the changes
Apply
Terraform calls the provider APIs to make the changes
Terraform uses the same language (HCL) and the same workflow to manage resources on any cloud provider or technology.
| Scenario | Without Terraform | With Terraform |
|---|---|---|
| Multi-cloud (AWS + Azure) | 2 tools, 2 languages, 2 different workflows | 1 HCL language, 1 init→plan→apply workflow |
| Reproducing the dev environment in staging | Manual process, prone to differences | Same configuration, different variables |
| Distributed team | Each person applies changes their own way | Git + PR + apply reviewed by everyone |
| Migrating from AWS to GCP | Rewrite everything with native GCP tools | Change the provider, adapt resources |
| On-prem + hybrid cloud | Different scripts per environment | VMware provider + AWS provider, same config |
💡 Provider-agnostic in practice
Terraform has providers for more than 3,000 services: AWS, Azure, GCP, Kubernetes, GitHub, Datadog, PagerDuty, Cloudflare, MongoDB Atlas, and many more. Everything is managed with the same language and the same workflow.
Terraform needs to know the current state of the infrastructure to calculate what changes to make. This mapping between configuration and real resources is stored in the state file (terraform.tfstate).
Mapping
Records which Terraform resource corresponds to which real resource (with its ID in the provider).
Diff
When running plan, Terraform compares the state with the configuration to know what to create, modify, or destroy.
Metadata
Stores dependencies between resources so they are destroyed in the correct order.
Performance
On large infrastructures, using state avoids refreshing every resource on each plan.
Collaboration
The remote state (S3, HCP Terraform) lets multiple people share the same state.
Secrets (⚠️)
State can contain sensitive values in plain text. Treat it as confidential data.
Terraform builds a directed acyclic graph (DAG) of all the resources. This lets it apply changes in parallel when safe, and serialize them when dependencies exist.
Example: VPC → Subnet → EC2
aws_vpc.main
Created first — no dependencies
aws_subnet.pub
Depends on aws_vpc.main (references vpc_id)
aws_instance.web
Depends on aws_subnet.pub (references subnet_id)
When destroying, the order is reversed: EC2 → Subnet → VPC.
🎯 For the exam
vpc_id = aws_vpc.main.iddepends_on = [aws_vpc.main] (explicit dependency)Did you get this topic?
Test what you just learned
What is the main purpose of the terraform.tfstate file?
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.