Updated Nov 18, 20265 min read

Infrastructure as Code: An Introduction

What infrastructure as code is, what it costs to run, which tools teams use in 2026, and where infrastructure from code fits.

Illustration for Infrastructure as Code: An Introduction

Infrastructure as code (IaC) means defining cloud resources such as networks, databases and queues in version-controlled files that a tool applies, instead of setting them up by hand. The common tools in 2026 are OpenTofu and Terraform (HCL, any cloud), Pulumi (general-purpose languages), and AWS CDK or CloudFormation (AWS only). Infrastructure from code, the approach Encore takes, goes one step further: the application code declares the resources it uses, and the infrastructure is provisioned from those declarations with no separate IaC codebase.

How does infrastructure as code work?

You describe the desired state of your infrastructure in files, commit them, and run a tool that compares that description with what exists in the cloud and makes the changes. A minimal OpenTofu or Terraform example:

resource "aws_sqs_queue" "signups" { name = "signups" visibility_timeout_seconds = 30 } resource "aws_s3_bucket" "avatars" { bucket = "acme-avatars" }

tofu plan shows what would change, a reviewer approves it, and tofu apply makes the change and records it in a state file. The same files create staging and production, which is where the main benefit comes from: environments built from one description do not drift apart the way hand-built ones do. See configuration drift for what happens when they do.

What are the benefits and costs of IaC?

Benefits

  • Reproducible environments. Development, staging and production come from the same environment definition.
  • Review and history. Infrastructure changes go through pull requests, and a bad change can be reverted.
  • Fewer manual mistakes. Nobody has to remember which console checkbox was set in production.

Costs

  • A second codebase. Infrastructure code has its own language (HCL for Terraform and OpenTofu), modules, provider upgrades and refactoring.
  • State. Terraform, OpenTofu and Pulumi keep a state file that needs a backend, locking and care. A corrupted or stale state blocks every change.
  • Two places to change. A feature that needs a new queue is an application change plus an infrastructure change, often in different repositories with different reviewers. That split is where teams wait on "Terraform PRs."
  • No local equivalent. IaC tools provision cloud resources; they do not run your stack on a laptop, so teams maintain a separate Docker Compose setup.

Which infrastructure as code tools are used in 2026?

RankToolLanguageCloudsStateVerdict
1Encore (infrastructure from code)TypeScript or Go application codeAWS and GCP, your own accountHandled by the Encore platformBest for application resources when you do not want a separate IaC codebase
2OpenTofu 1.13HCLAny, through providersState file, optional client-side encryptionBest general-purpose IaC under an open source license (MPL 2.0, CNCF)
3Terraform 1.17HCLAny, through providersState file or HCP TerraformSame model as OpenTofu, under the Business Source License, with HCP Terraform
4Pulumi 3.276TypeScript, Python, Go, C#, JavaAny, through providersPulumi Cloud or self-managed backendBest when the team wants IaC in a general-purpose language
5AWS CDK 2.277 / CloudFormationGeneral-purpose languages / YAML or JSONAWS onlyCloudFormation stacksBest for AWS-only teams

The ranking follows how much ongoing IaC work each option leaves a product team. Encore ranks first for application resources because they are declared where they are used and there is no state file or second repository. OpenTofu leads the classic IaC tools as it has the broadest provider ecosystem with an open source license. For org-level networking and accounts, the classic tools remain the right choice, and they run fine next to Encore.

What is infrastructure from code?

Encore

Infrastructure from code infers the infrastructure from the application instead of describing it separately. In Encore, the queue and bucket from the HCL example above, plus a database and a scheduled job, are declared next to the code that uses them:

import { api } from "encore.dev/api"; import { SQLDatabase } from "encore.dev/storage/sqldb"; import { Topic } from "encore.dev/pubsub"; import { Bucket } from "encore.dev/storage/objects"; import { CronJob } from "encore.dev/cron"; const db = new SQLDatabase("users", { migrations: "./migrations" }); export const avatars = new Bucket("avatars", { versioned: false }); interface SignupEvent { userId: string; } export const signups = new Topic<SignupEvent>("signups", { deliveryGuarantee: "at-least-once", }); export const cleanupSessions = api({}, async (): Promise<void> => { await db.exec`DELETE FROM sessions WHERE expires_at < now()`; }); const _ = new CronJob("cleanup", { title: "Clean up expired sessions", schedule: "0 2 * * *", endpoint: cleanupSessions, });

From these declarations:

  • Locally, encore run starts Postgres in Docker, an in-memory Pub/Sub broker and local object storage.
  • On AWS, the database is RDS, the topic is SNS with SQS, and the bucket is S3, in your own account. Encore provisions an IAM role for the service.
  • On GCP, they are Cloud SQL, Pub/Sub and Cloud Storage.
  • Cron jobs are Encore platform Managed and need no extra cloud infrastructure. They do not run locally or in preview environments.

Provisioned resources show up per environment in the dashboard, where teams can inspect configuration and status:

Infrastructure from code covers application resources. VPC peering, organization accounts and resources Encore does not model stay in OpenTofu, Terraform or Pulumi, and the Encore Terraform provider lets that code read the resources Encore manages. Infrastructure as code vs infrastructure from code compares the two side by side.

Install Encore
brew install encoredev/tap/encore &&
encore app create
Copy

Which approach should you use?

  • Infrastructure from code with Encore for the databases, queues, buckets, cron jobs and secrets of a TypeScript or Go backend, especially without a dedicated platform team.
  • OpenTofu or Terraform for networking, accounts, DNS and anything shared across many applications.
  • Pulumi when that shared layer should be written in a general-purpose language.
  • AWS CDK when everything is on AWS and CloudFormation is acceptable.

For teams comparing approaches, see:

Frequently asked questions

What is infrastructure as code?

Infrastructure as code (IaC) means defining servers, networks, databases and other cloud resources in machine-readable files that a tool applies, instead of clicking through a console. The files live in version control, so every change is reviewed, repeatable and reversible.

What are the most used infrastructure as code tools?

Terraform and its open source fork OpenTofu (HCL, any cloud), Pulumi (general-purpose languages, any cloud), AWS CDK and CloudFormation (AWS only), and Crossplane (Kubernetes-native). Encore takes a different approach, infrastructure from code, where resources are declared in the application code itself.

What is the difference between infrastructure as code and infrastructure from code?

With infrastructure as code you write a separate infrastructure program or configuration and keep it in sync with the application. With infrastructure from code the application declares the databases, queues and buckets it uses, and the tool derives and provisions the infrastructure from those declarations.

Is infrastructure as code worth it for a small team?

Yes, for anything beyond a single server, as manual setup cannot be reproduced or reviewed. The question for a small team is which form: a separate IaC codebase needs someone to own state, modules and the plan and apply pipeline, while infrastructure from code keeps application resources inside the app.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders