Terraform Is Like LEGO: Building Infrastructure One Block at a Time

When I began my journey learning about Infrastructure as Code, I had no idea how much it would change the way I thought about infrastructure.

At first, Terraform was simply another technology to learn. You write some code, run a few commands, and infrastructure appears in the cloud.

But over time, I began to see something much bigger.

I started thinking about the possibilities.

What if infrastructure could be designed once and reused across multiple environments? What if organizations could use multiple cloud providers for business continuity? What if infrastructure could automatically scale when demand increased and scale back down when those resources were no longer needed?

What if disaster recovery environments didn’t have to be manually rebuilt during a disaster?

And what if all of those lessons—security practices, networking configurations, monitoring, storage and compute—could be packaged into reusable building blocks?

That’s when Terraform started reminding me of something much simpler.

LEGO.


Is Terraform Really LEGO for Technologists?

Think about building something complicated with LEGO.

Maybe you’re building a city.

You don’t think of the entire city as one enormous object. You see buildings, roads, bridges, houses and other pieces that eventually connect to form something much larger.

Infrastructure can work the same way.

Imagine that we want to build infrastructure capable of hosting a self-hosted AI platform.

Our AI workloads need serious computing power, so perhaps we decide to run them across a Kubernetes cluster. We use Ray to distribute AI workloads across our available compute resources. We add autoscaling so additional resources can be provisioned when demand increases.

Suddenly, our project needs quite a few things:

  • networking,
  • subnets,
  • security groups,
  • compute,
  • Kubernetes,
  • storage,
  • load balancing,
  • monitoring,
  • autoscaling,
  • databases,
  • and identity and access controls.

That sounds complicated.

And it is.

But here’s where the LEGO concept becomes useful.

Instead of treating that entire architecture as one massive project, we can break it into reusable infrastructure components.

Think of each Terraform module as a LEGO set.

One module builds the Virtual Private Cloud.

Another builds the storage.

Another builds the database.

Another handles compute.

Another handles monitoring.

Another might deploy the Kubernetes cluster.

                    AI PLATFORM
                         │
          ┌──────────────┼──────────────┐
          │              │              │
      NETWORK         COMPUTE        STORAGE
          │              │              │
       VPC Module     EKS Module     S3/EFS Module
          │
      ┌───┴────┐
      │        │
   Public    Private
   Subnets   Subnets

Now we’re building infrastructure with building blocks.

And those blocks can be combined, replaced, upgraded and reused depending on what we’re trying to build.

Sound familiar?


The Instructions Matter Just as Much as the Bricks

Dump a giant box of LEGO onto a table and you have plenty of resources.

But you don’t necessarily have a building.

You need instructions.

Terraform configuration provides those instructions.

A simple configuration might say:

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

We’re essentially telling Terraform:

I need a network, and this is how I want that network configured.

Now imagine doing that for the rest of our infrastructure.

Network.

Compute.

Storage.

Database.

Security.

Monitoring.

The individual resources become part of a larger design.

This is one of the ideas behind declarative infrastructure: instead of manually describing every button someone needs to click, we describe the state we want our infrastructure to be in.

Terraform works toward creating that state.


From a Pile of Bricks to Infrastructure

This is also why I like thinking about terraform plan and terraform apply in LEGO terms.

Before building an expensive LEGO set, you’d probably look at the instructions.

Terraform gives us something similar:

terraform plan

A Terraform plan allows us to preview what Terraform intends to change before those changes are made.

Maybe Terraform tells us:

+ Create VPC
+ Create 3 private subnets
+ Create 3 public subnets
+ Create EKS cluster
+ Create database
+ Create load balancer
+ Create monitoring resources

We’re essentially looking at the instructions before assembling the pieces.

Then comes:

terraform apply

That’s when Terraform begins assembling our infrastructure.

Our pile of cloud resources starts becoming an architecture.


Why Should a Business Care About Any of This?

This is where Infrastructure as Code stops being an engineering curiosity and starts becoming a business capability.

Suppose your company needs the same application environment for:

Development → Testing → Staging → Production

If engineers manually build each environment, subtle differences inevitably appear.

Maybe production has a firewall rule that staging doesn’t.

Maybe someone selected the wrong instance size.

Maybe development was created six months ago and nobody remembers exactly how it was configured.

Or perhaps the engineer who originally built the environment no longer works for the company.

Now someone has to reverse-engineer it.

Terraform gives us something incredibly valuable:

Repeatability.

The same infrastructure definition can be version controlled, reviewed, tested and reused.

Instead of saying:

“I think Steve configured production sometime last year.”

we can say:

“This Git commit defines how production is built.”

That’s a very different way of operating infrastructure.

And when the infrastructure changes, the change can be reviewed just like application code.

Who changed it?

Why was it changed?

When did it change?

What was the previous configuration?

Can we reproduce it?

Those become much easier questions to answer when infrastructure is represented as code.


Can Terraform Dismantle the LEGO Set Too?

Absolutely.

Terraform can build your infrastructure.

It can modify your infrastructure.

And yes, it can dismantle it too.

terraform destroy

Think of this as taking apart the LEGO model and putting the pieces back into the box.

This is extremely useful for temporary environments.

Imagine a development team needs a large test environment for three days.

Terraform can create it.

The team performs its testing.

When testing is complete, Terraform removes the environment.

The company stops paying for resources it no longer needs.

That’s one way Infrastructure as Code can contribute to cost optimization.

But there’s an important difference between LEGO and cloud infrastructure.

If you accidentally dismantle your LEGO castle, someone might be upset.

If you accidentally dismantle production infrastructure at 2:00 PM on a Tuesday…

your calendar is probably about to become very busy.

Automation gives us tremendous power, which means it also requires safeguards.

Production infrastructure should include protections such as code review, approval workflows, least-privilege permissions, protected state, backups, policy validation and audit logging.

The goal isn’t simply to automate.

The goal is to automate responsibly.


The Bigger Idea

Terraform isn’t really about eliminating clicking.

It’s about turning infrastructure into something we can treat like software.

We can:

Write it.

Review it.

Version it.

Test it.

Reuse it.

Secure it.

Automate it.

And increasingly, we can allow AI systems to help us design and operate it.

That’s where I think infrastructure becomes particularly interesting.

Imagine telling an AI infrastructure agent:

“Build a highly available application environment across three availability zones. Keep the database private, encrypt sensitive data, automatically scale the application and minimize unnecessary cloud costs.”

The AI could help design the architecture.

Terraform could describe the infrastructure.

Policy engines could validate it.

CI/CD could test it.

Security tools could inspect it.

A human could approve it.

And the cloud platform could build it.

              HUMAN INTENT
                    │
                    ▼
             AI / ENGINEER
                    │
                    ▼
        TERRAFORM CONFIGURATION
                    │
                    ▼
            TERRAFORM PLAN
                    │
                    ▼
       SECURITY / POLICY CHECKS
                    │
                    ▼
            HUMAN APPROVAL
                    │
                    ▼
            TERRAFORM APPLY
                    │
                    ▼
          CLOUD INFRASTRUCTURE
                    │
                    ▼
       MONITORING + OBSERVABILITY

We’re moving from manually building infrastructure toward declaring what infrastructure should accomplish.

And that’s a much bigger idea than simply replacing buttons with code.


So, Is Terraform Really LEGO for Grown-Ups?

Pretty much.

Except these LEGO bricks charge you by the hour.

Some contain databases.

Some store customer information.

Some are connected to the Internet.

Some can automatically create hundreds of other bricks.

And if something happens to your Terraform state, your afternoon may suddenly become much more interesting.

But the fundamental idea is surprisingly similar:

Small, reusable components + clear instructions = complex systems.

One LEGO block can represent networking.

Another can represent compute.

Another can represent storage.

Another can represent a database.

Another can represent security.

Individually, they’re infrastructure resources.

Put them together correctly and they become an architecture.

And unlike the LEGO city sitting on your kitchen table, this architecture might be running the applications, AI systems and digital services that an entire business depends on.

That’s what makes Infrastructure as Code so powerful.

We’re not simply automating infrastructure.

We’re creating reusable building blocks for the systems that come next.

Build once. Version it. Secure it. Reuse it. Automate it.

Engineering the Future of Intelligent Infrastructure — InfraModule

Leave a comment

Your email address will not be published. Required fields are marked *

Let’s look at what you’re running

A free consultation, no obligation: tell us what you have and what hurts, and we will tell you honestly whether we can help.