Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
HashiCorp · Terraform 004

Infrastructure as code with Terraform

Terraform 004 · Lesson 1 of 18 · 4:00

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the HashiCorp Terraform Associate (004) exam. In this lesson: what infrastructure as code is, its advantages (version control, reuse, review, consistency), how Terraform works with providers and a declarative configuration, and one workflow for many clouds, on-premises systems, and services. Includes three original practice questions, with Bluefin Logistics, a fictional parcel delivery company, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

Clicks in a console

At Bluefin Logistics, the platform team builds servers, networks, and databases by clicking in cloud consoles. The test environment no longer matches production, nobody knows who changed a firewall rule last week, and rebuilding a region after an outage would take days. This lesson covers infrastructure as code, its advantages, and how Terraform manages any cloud and any service.

What infrastructure as code is

Infrastructure as code means managing infrastructure with configuration files, rather than through a graphical interface or by hand. You describe the servers, networks, and databases you want in text files, and a tool builds, changes, and manages them for you. Because they are files, you can version them, reuse them, and share them, like application code. Terraform is HashiCorp's infrastructure as code tool, and its files use HCL, the HashiCorp Configuration Language, which people and machines can both read.

The advantages

Infrastructure as code has clear advantages. It is repeatable and consistent: the same files build the same environment every time, so test can match production. It is versioned: changes go through version control and code review, and you can roll back to a known version of the files. It is reusable: one configuration, or a module, can build many environments. And it is faster and safer: Terraform shows you a plan of every change before it makes it, and builds a whole region in minutes, without manual steps to forget.

How Terraform works

Terraform's language is declarative: you describe the end state you want, such as three servers behind a load balancer, and not the steps to get there. A procedural script lists the steps, and you must handle every case yourself, like servers that already exist. Terraform compares what you declared with what exists, and works out the changes, in the right order, because it knows the dependencies between resources. It talks to each platform through plugins called providers, which call that platform's API, and the Terraform Registry lists thousands of them. Terraform also keeps a state file, its record of what it manages.

Multi-cloud, hybrid, and any service

Terraform manages multi-cloud workflows: one configuration can create resources on AWS and on Azure, with the same language, the same commands, and dependencies across both clouds. Using several clouds can help you survive the outage of one provider, but each cloud has its own consoles and tools, and Terraform gives you one workflow for all of them. It also manages hybrid cloud: providers exist for systems in your own data center, so cloud and on-premises resources live in the same workflow. And Terraform is service-agnostic: anything with an API can have a provider, such as DNS records, monitoring dashboards, Kubernetes, or GitHub repositories. Bluefin can manage its cloud networks, its warehouse servers, and its GitHub teams with the same workflow.

Recap

Let's recap. Infrastructure as code manages infrastructure with configuration files, which you can version, reuse, and share. Its advantages: repeatable, versioned and reviewed, reusable, and safer, with a plan before every change. Terraform is declarative: you describe the end state, and it works out the changes and their order, through providers that call each platform's API. And one workflow covers multi-cloud, hybrid, and any service with an API.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. The Bluefin team wants every change to its network reviewed by a colleague before it happens, with a record of who changed what. Which practice gives them this?

    • Keep using the console, with screenshots
    • Write a wiki page that describes the network
    • Network files under version control
    • Turn on an audit log of console changes
    Show the answer

    Network files under version control

    With the network in configuration files under version control, every change goes through a pull request and a review, and the history shows who changed what. “Keep using the console, with screenshots” would keep the clicks, with no review before the change. “Write a wiki page that describes the network” would document the network, but nothing would stop changes made in the console. And “Turn on an audit log of console changes” would only record the changes after they happened.

  2. A configuration declares three web servers. Two already exist, because Terraform created them last week. What does Terraform do when the engineer applies the configuration?

    • Creates only the one missing server
    • Creates three new servers, five in total
    • Replaces the two servers, then adds one
    • Fails, because two servers already exist
    Show the answer

    Creates only the one missing server

    Terraform is declarative, so it compares the three servers in the configuration with the two it already manages, and creates only the missing one. “Creates three new servers, five in total” is what a simple procedural script might do, without checking what exists. “Replaces the two servers, then adds one” would not happen, because nothing in the configuration changed for the two existing servers. And “Fails, because two servers already exist” is wrong, because handling existing resources is exactly what Terraform's state is for.

  3. Bluefin runs its API on AWS, its analytics on Azure, and its DNS records with a DNS company. The team wants one tool and one workflow for all three. What makes this possible?

    • Moving every resource into a single cloud first
    • A module that replaces the need for providers
    • Converting Azure resources into AWS resources
    • One configuration that uses three providers
    Show the answer

    One configuration that uses three providers

    Each platform has its own provider, and one configuration can use all three providers, with the same commands and the same workflow. “Moving every resource into a single cloud first” would be wrong, because Terraform does not require resources to sit in a single cloud. “A module that replaces the need for providers” would not help, because a module is a group of resources, and it still needs providers to reach each platform. And “Converting Azure resources into AWS resources” is not needed, because Terraform does not convert one cloud's resources into another's: each provider manages its own platform.