Infrastructure as Code (IaC) turns the messy, manual process of setting up servers, networks, and databases into something reliable and repeatable — like following a recipe instead of cooking by instinct. For the TF-003 exam, understanding IaC is the foundation of everything else, because Terraform is the most popular tool in the world for doing IaC well. If you grasp why IaC matters and what problems Terraform solves, you will already understand the core purpose behind every Terraform command you learn later.
Jump to a section
A simple way to picture Introduction to Infrastructure as Code and Terraform
An architectural blueprint is a detailed, machine-readable plan for a building. It specifies every wall, pipe, socket, and window before any construction begins.
Without a blueprint, each builder makes decisions as they go. The electrician guesses where to put outlets, the plumber runs pipes through walls without coordinating, and the carpenter builds a wall that blocks a vent. The result is a house that works but is full of hidden problems, takes longer to build, and costs far more than planned. If you want a second house just like the first, you have to rebuild it from scratch because nobody remembers exactly what was done.
A blueprint changes everything. You design the entire building once, in exact detail. Everyone follows the same plan. You can build the same house in a different location by handing the same blueprint to a new crew. If you want ten houses, you give all ten crews copies of the same blueprint. If you discover a mistake, you fix the plan once and every future house is built correctly. This is exactly how Infrastructure as Code works. Instead of manually clicking and guessing, you write a declarative plan — your blueprint — that defines your entire IT setup. Terraform is the program that reads that blueprint and builds exactly what it says, every single time, without the manual mistakes.
Infrastructure as Code (IaC) is the practice of managing and provisioning your IT infrastructure — the servers, networks, databases, and other components that make a website or app work — using machine-readable definition files rather than manual clicks or ad-hoc scripts. Instead of a human logging into a cloud console to create a server by hand, you write a text file that describes exactly what that server should be, and a tool like Terraform reads that file and creates it automatically.
Before IaC, the standard way to set up infrastructure was manual. An IT professional would click through a web interface, choose settings, and wait for the server to spin up. If they needed ten servers, they clicked ten times. If they made a mistake on server five, they either fixed it manually or started over. This process was slow, error-prone, and impossible to reproduce exactly. Getting a second environment that matched the first was a huge challenge.
Terraform, created by HashiCorp, is an open-source IaC tool that uses a declarative language called HCL (HashiCorp Configuration Language). Declarative means you write what you want the final result to be, not the step-by-step instructions to get there. For example, you write 'I want a virtual machine with 4 CPUs and 16GB of RAM running Ubuntu 22.04', and Terraform figures out the exact API calls needed to create it. Other tools like Ansible or Chef are imperative — they require you to write the exact sequence of steps ('install this package, then edit this config file, then restart the service').
The key concepts you need to know for TF-003 are:
Provisioning: The act of creating and setting up IT infrastructure — servers, databases, load balancers, etc.
Configuration management: Managing software on existing servers — installing packages, editing config files, starting services. Terraform is not a configuration management tool; it handles provisioning.
Orchestration: Coordinating multiple tasks or resources to work together — for example, creating a server, then installing an app on it, then connecting it to a load balancer.
Immutable infrastructure: The practice of never modifying a running server. Instead of patching an old server, you destroy it and build a new one from a known good image. Terraform supports this model perfectly.
Why does IaC matter? Three reasons:
Repeatability: Run the same code today, next week, or next year, and you get the identical infrastructure every time. No human memory required.
Version control: Your infrastructure definitions live in a file, just like source code. You can track changes, roll back mistakes, and collaborate with your team using Git.
Speed: Creating a complex multi-server environment takes minutes instead of days or weeks.
For the TF-003 exam, the syllabus says you must learn objective 1.1: Explain infrastructure as code (IaC) concepts and the benefits of using Terraform. This means you will need to be able to pick out the correct definition of IaC, name its advantages over manual methods, and understand where Terraform fits in the broader IaC landscape. The exam will not ask you to write HCL code for this objective, but it will ask you to recognise key terms and concepts.
Write the Configuration File
You create a .tf file (e.g., main.tf) written in HCL (HashiCorp Configuration Language). This file declares what infrastructure you want — for example, one server with 4 CPUs and 16GB RAM. You do not write the steps to create it; you describe the desired end result.
Initialise the Project
You run 'terraform init' in your terminal. This command downloads the necessary provider plugins (like the AWS or Azure plugin) that Terraform needs to communicate with your cloud provider. It also sets up the backend for storing the state file.
Review the Execution Plan
You run 'terraform plan'. Terraform compares your desired state (from the .tf file) with the current state (from the state file) and shows you exactly what it will create, modify, or destroy. This gives you a chance to catch mistakes before making any changes.
Apply the Configuration
You run 'terraform apply'. If you approve the plan, Terraform makes the necessary API calls to your cloud provider to create, update, or delete resources. It updates the state file to reflect the new current state of your infrastructure.
Manage Changes Over Time
When you need to scale up or modify your infrastructure, you edit the .tf file (for example, changing the server count from 1 to 5), run plan again to review the changes, and then apply. Terraform handles the delta — it only changes what needs to change, without touching other resources.
Consider a real company called QuickCart, a small e-commerce startup. They have a website built by a developer, 'Sam', who manually set up everything on a single cloud server. Sam clicked through the AWS console to create a server, installed a web server, configured a database, and deployed the app. It worked fine for six months.
Then QuickCart got popular. The server became too slow. Sam needed to add a second server and a load balancer (a device that distributes traffic across multiple servers). Sam also needed a separate staging environment (a copy of the production environment for testing changes without breaking the live site).
Without IaC, Sam would have to manually recreate the entire setup from memory — choose the same instance type, the same operating system, the same security group rules, the same database settings. Sam would inevitably miss something. The staging environment would be slightly different from production — maybe a different version of MySQL or a different security rule. When they tested a new feature on staging, it would work fine, but when they deployed to production, it would break because the environments did not match.
With Terraform, Sam would write a configuration file describing every resource: one server for the app, one database instance, one load balancer, and all the networking rules. When QuickCart needed a staging environment, Sam would run 'terraform apply' with a different variable for the environment name. Terraform would create an identical copy in minutes. When the marketing team announced a flash sale, Sam could scale up by changing a number in the Terraform file from 'instance_count = 2' to 'instance_count = 5' and running apply.
An IT professional setting up this project would follow these steps:
Write a main.tf file that defines the cloud provider (AWS, Azure, Google Cloud) and the resources needed.
Run 'terraform init' to download the necessary provider plugins.
Run 'terraform plan' to see what resources Terraform intends to create, without making any changes.
Review the plan to catch mistakes — for example, noticing that a security group is open to the entire internet when it should be restricted.
Run 'terraform apply' to create the infrastructure.
Store the Terraform state file (which tracks what resources exist) in a shared location like an S3 bucket so the team can all work on the same base configuration.
When changes are needed, edit the .tf files, run plan, review, and apply again.
The business impact is huge. QuickCart saves hours of manual work, removes the risk of human error, and can spin up entire environments on demand. This is why companies pay for Terraform skills — they want reliability and speed.
The TF-003 exam tests objective 1.1 in a very specific way. You will not be asked to write a Terraform configuration for this objective. Instead, you will be asked to choose the correct definition of IaC, identify its benefits, or recognise which problem Terraform solves. The exam uses multiple-choice and multi-select questions, and the traps are designed to catch people who learned the concepts superficially.
Here are the exact concepts they love to test:
Definition of Infrastructure as Code: They will give you a description and ask: 'Which of these best describes IaC?' The correct answer will link to managing infrastructure through machine-readable definition files. The trap will be an answer that sounds similar but describes configuration management or containerisation.
Benefits of IaC: Repeatability, version control, speed, reduced human error. They will list a benefit that is false (like 'IaC eliminates the need for developers') and you must spot it. You must memorise these benefits cold.
Declarative vs imperative: They will ask you what 'declarative' means in the context of Terraform. Expect a question like: 'Terraform uses a declarative approach. What does that mean?' The correct answer will be that you define the desired end state, not the steps to get there.
Terraform vs other tools: They will compare Terraform to Ansible, Chef, Puppet, or CloudFormation. You need to know that Terraform is declarative, cloud-agnostic (works with multiple providers), and handles provisioning (not configuration management).
Immutable infrastructure: A newer concept they love. They might ask: 'Which approach does Terraform support by encouraging you to replace rather than modify resources?' The answer is immutable infrastructure.
State file: They will not ask deep questions about state in objective 1.1, but they may ask you to identify what the state file does — tracks the current state of resources.
Common traps to watch for:
The exam will offer an answer that says 'IaC allows you to manage infrastructure using shell scripts'. This is wrong because shell scripts are imperative and not declarative IaC.
They will offer 'Terraform is a configuration management tool'. This is wrong. Terraform is a provisioning tool.
They will offer 'IaC means you do not need to understand infrastructure'. This is obviously false, but beginners might fall for it.
They will ask about 'idempotency' — the property that running the same code multiple times produces the same result. Terraform is idempotent. They might not use that word, but they will test the concept.
To pass this section, memorise the definitions, the benefits, and be able to distinguish Terraform from other tools. Use flashcards if you need to. This is the easiest objective on the exam if you prepare correctly — do not overthink it.
Infrastructure as Code (IaC) is the practice of managing and provisioning IT infrastructure using machine-readable definition files, not manual processes.
Terraform uses a declarative language (HCL) where you specify the desired end state, not the step-by-step commands to reach it.
The primary benefits of IaC are repeatability, version control, speed, and reduced human error.
Terraform is a provisioning tool, not a configuration management tool — it creates resources but does not install software on them.
IaC supports immutable infrastructure, meaning you replace servers instead of patching them, ensuring consistency across environments.
The state file is Terraform's record of what resources currently exist, and it is stored locally by default but should be shared with your team for collaboration.
IaC works with multiple cloud providers (cloud-agnostic), which is a key differentiator from vendor-specific tools like AWS CloudFormation.
These come up on the exam all the time. Here's how to tell them apart.
Terraform
Provisioning tool — creates servers, databases, networks
Declarative — you define the desired end state
Cloud-agnostic — works with AWS, Azure, GCP, and others
Ansible
Configuration management tool — installs software, configures settings
Imperative (by default) — you define the steps to reach the end state
Primarily focused on existing servers, though it can also provision
Infrastructure as Code (IaC)
Uses machine-readable files that can be version-controlled
Repeatable — same code produces same infrastructure every time
Faster — entire environments created in minutes
Manual (ClickOps)
Requires human clicks through a GUI
Error-prone — different people may make different choices
Slower — each resource must be created one by one
Declarative Approach
You specify the desired end state ('I want 3 servers with 4 CPUs each')
Terraform automatically computes the steps to get there
Idempotent — running it multiple times gives the same result
Imperative Approach
You specify the exact steps ('create server, install OS, configure network')
You manually handle the order and dependencies
Not inherently idempotent — running it again may fail if things already exist
Immutable Infrastructure
Never modify running servers — replace them instead
Consistent — every new server is identical to the golden image
Easier to roll back — replace with a known good version
Mutable Infrastructure
Servers are patched and updated in place over time
Configuration drift occurs — servers become different over time
Harder to debug — have to log into an old server to see what changed
Mistake
Infrastructure as Code means you write code to replace system administrators entirely.
Correct
IaC automates the provisioning and management of infrastructure, but it still requires skilled professionals to design, write, and review the IaC code and to handle incidents and architecture decisions.
The term 'code' makes people think it is a replacement for human operators, when in reality it is a tool that makes operators more efficient by removing repetitive manual work.
Mistake
Terraform and Ansible do the same thing — you can use either one to achieve the same outcome.
Correct
Terraform is a provisioning tool focused on creating and managing infrastructure resources (servers, networks, databases), while Ansible is a configuration management tool focused on installing software and configuring settings on existing servers. They complement each other but are not interchangeable.
Both tools are used for automation, and beginners often hear 'automation tool' and assume they are the same. The exam tests your ability to distinguish them.
Mistake
Once you write a Terraform config, you never need to touch infrastructure again — it is completely hands-off.
Correct
Terraform automates the initial creation and ongoing updates, but you still monitor the infrastructure, respond to failures, update Terraform versions, and occasionally refactor your code as requirements change.
The promise of 'automation' sounds like a set-it-and-forget-it solution, but real-world infrastructure still needs human attention for unexpected events and upgrades.
Mistake
IaC is only useful for large companies with complex, multi-cloud environments.
Correct
IaC is valuable for any size organisation because it reduces human error, provides repeatability, and saves time — even a small startup with one server benefits from being able to recreate that server from code after a failure.
People see cloud and IaC as enterprise-only technologies, but the cost of manual work scales linearly, so even small teams save significant time using IaC.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
No. Terraform uses HCL, which is a simple declarative language that looks like configuration files, not a general-purpose programming language. You do not need to know Python or JavaScript to use it.
Docker is a containerisation platform that packages applications so they run consistently anywhere. Terraform provisions the infrastructure (like servers) that Docker runs on. They solve different problems and are often used together.
Yes, Terraform is open source and free. There is also a paid commercial version called Terraform Cloud that adds collaboration features like remote state management and private module registry.
Yes, but you have to import those resources into Terraform's state file using 'terraform import'. This tells Terraform to adopt the existing resource so it can manage it going forward.
You only need to run 'terraform init' when you first set up a project or when you add new providers or modules. It downloads the necessary plugins. You do not need to run it every time you make a small change.
Terraform loses track of what resources it created. Applying again may create duplicates or cause errors. This is why you should store the state file in a remote backend (like an S3 bucket) for important projects.
Cloud-agnostic means Terraform works with multiple cloud providers (AWS, Azure, Google Cloud, etc.) using the same language and workflow. This matters because you can switch providers or use multiple providers without learning a new tool for each one.
You've finished Introduction to Infrastructure as Code and Terraform. Continue through the TF-003 study guide to build a complete picture of the exam.
Done with this chapter?