DevOps
DevOpsIntermediate

Terraform vs Pulumi: HCL Simplicity or Real Programming Languages?

Terraform vs Pulumi compared with real code examples, architecture diagrams, tf-bridge internals, Pulumi Cloud vs HCP Terraform pricing, AI-coding trade-offs, and a clear decision matrix.

Cover image: Terraform vs Pulumi: HCL Simplicity or Real Programming Languages?
Contents

Every platform team eventually hits the same fork in the road. Someone opens a pull request with 350 lines of HCL nested inside three for_each maps and conditional dynamic blocks, looks up from the screen, and asks: “Why aren’t we just writing this in TypeScript or Python?”

That exact frustration built Pulumi. Yet years after its launch, search demand for “pulumi alternatives” is climbing while Terraform (and its open-source fork OpenTofu) still power the majority of production cloud landing zones. Why? Because turning infrastructure into real software solves five real engineering problems — and quietly imports five new ones.

Terraform vs Pulumi: declarative HCL monolith blocks versus dynamic multi-language TypeScript and Python infrastructure code

This guide skips the marketing slogans and compares how Terraform and Pulumi actually behave in production: side-by-side code, what happens under the hood (tf-bridge), real SaaS pricing, how AI coding agents handle both, and a clear decision matrix.

(Already using HCL and wondering about the licensing split? Read OpenTofu vs Terraform first, or check Ansible vs Terraform if you are separating provisioning from configuration management.)

Two Philosophies: Constrained Spec vs. General-Purpose Code

The difference between Terraform and Pulumi is not syntax — it is what the language intentionally forbids.

Terraform uses HCL (HashiCorp Configuration Language), a declarative domain-specific language. You cannot import an HTTP client, read a database mid-run unless there is a data source for it, or write a recursive helper function. That limitation is a feature: every .tf file is essentially a typed graph of desired state. When an engineer reviews a pull request, they know nothing unexpected can execute during plan.

Pulumi uses general-purpose programming languages — TypeScript/JavaScript, Python, Go, C#, Java, or YAML. Your infrastructure is a real program executed by a language runtime (Node.js, Python, Go). You get if/else, for loops, classes, npm/PyPI packages, IDE autocomplete, and real unit tests before a single cloud API call happens.

Architecture comparison under the hood: Terraform HCL to Graph Engine to Native Go Providers and S3/GCS State versus Pulumi TypeScript/Python Language Host to Deployment Engine to Native Providers or pulumi-terraform-bridge and Pulumi Cloud or S3 State
Under the hood: Terraform runs native Go providers directly, while Pulumi separates the language runtime from the engine — and often bridges Terraform providers.

Look closely at the bottom layer of that diagram. It reveals the detail most comparison posts gloss over: the tf-bridge.

Side-by-Side Example: S3 Bucket + Encryption + Multi-Environment Loop

To see where each tool shines, let’s build the exact same production slice: a private, versioned, KMS-encrypted S3 bucket per environment (staging, prod) with strict public-access blocks.

Terraform (HCL)

variable "environments" {
type = set(string)
default = ["staging", "prod"]
}
resource "aws_s3_bucket" "artifacts" {
for_each = var.environments
bucket = "acme-artifacts-${each.key}"
tags = {
Environment = each.key
ManagedBy = "terraform"
}
}
resource "aws_s3_bucket_versioning" "artifacts" {
for_each = aws_s3_bucket.artifacts
bucket = each.value.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket_public_access_block" "artifacts" {
for_each = aws_s3_bucket.artifacts
bucket = each.value.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}

Pulumi (TypeScript)

import * as aws from "@pulumi/aws";
const environments = ["staging", "prod"] as const;
export const bucketNames = environments.map((env) => {
const bucket = new aws.s3.BucketV2(`artifacts-${env}`, {
bucket: `acme-artifacts-${env}`,
tags: { Environment: env, ManagedBy: "pulumi" },
});
new aws.s3.BucketVersioningV2(`artifacts-ver-${env}`, {
bucket: bucket.id,
versioningConfiguration: { status: "Enabled" },
});
new aws.s3.BucketPublicAccessBlock(`artifacts-pab-${env}`, {
bucket: bucket.id,
blockPublicAcls: true,
blockPublicPolicy: true,
ignorePublicAcls: true,
restrictPublicBuckets: true,
});
return bucket.bucket;
});

At 30 lines, they look almost identical. The divergence starts at 3,000 lines:

  • Where Pulumi wins: If you want to wrap those three resources into a reusable SecureArtifactBucket class with strict TypeScript interfaces, share the environments enum directly with your backend app, or run Jest/Pytest mocks in 200ms without touching AWS, Pulumi feels effortless. Terraform modules require separate directories, boilerplate variables.tf / outputs.tf files, and terraform test is still much younger.
  • Where Terraform wins: Six months later, a junior engineer opens the Pulumi repo and has to debug a TypeScript upgrade, broken transitive npm dependencies, or an engineer who got “clever” with dynamic promises (pulumi.all([...]).apply(...)) that make pulumi preview hard to trace. In Terraform, for_each is ugly — and that ugliness stops people from building overly clever abstractions.

HCL’s lack of expressiveness is a guardrail. Real programming languages remove that guardrail — which feels liberating on day one and demands strict code-review discipline by year two.

Licensing, State Backends, and Real Pricing

Both tools let you run completely for free if you host your own state in Amazon S3, Google Cloud Storage, or Azure Blob Storage (and run plan/apply in GitHub Actions, GitLab CI, or Atlantis). The differences show up when you look at licensing and managed SaaS platforms.

Licensing, State Backends, and Real Pricing
Dimension Terraform OpenTofu Pulumi
License BUSL 1.1 (source-available, IBM/HashiCorp) MPL-2.0 (OSI open-source, Linux Foundation) Apache-2.0 (CLI & SDKs)
Language HCL (declarative) HCL (declarative) TypeScript, Python, Go, C#, Java, YAML
Free Self-Hosted State S3, GCS, Azure Blob, Postgres, GitLab S3, GCS, Azure Blob (+ native state encryption) S3, GCS, Azure Blob (loses Pulumi Cloud UI)
Managed Cloud Free Tier HCP Terraform Free (up to 500 resources) N/A (use Spacelift, env0, Scalr, GitLab) Pulumi Cloud Free (1 user, 500 workflow min/mo)
Managed Team / Pro Essentials approx. $0.10, Standard approx. $0.47, Premium approx. $0.99 / resource / mo Vendor-dependent (usually per-seat or runner) Essentials $40/mo (500 resources), Pro $400/mo (2,000 resources)
Policy as Code Sentinel (paid) or OPA / Checkov OPA / Kyverno / Checkov CrossGuard (TS/Python/OPA)
Programmatic Embedding CLI wrapper / CDKTF CLI wrapper First-class Automation API

Two pricing traps catch teams off guard:

  1. Pulumi Cloud defaults to SaaS state. When a developer runs pulumi up for the first time, state goes to Pulumi Cloud. Moving from 1 developer to a team pushes you to Essentials ($40/mo for 40 credits covering up to 500 resources) or Pro ($400/mo for 2,000 resources, SSO, and drift detection), with overages roughly $0.18–$0.37 per extra resource/month. You can switch to pulumi login s3://my-state-bucket, but you give up Resource Search, the web diff UI, and Pulumi Deployments.
  2. HCP Terraform scales steeply on Premium. Essentials (approx. $0.10/resource/mo) is cheap, but features enterprises actually want — Terraform Stacks, Sentinel policy enforcement, and higher concurrency — sit in Standard (approx. $0.47/resource/mo) and Premium (approx. $0.99/resource/mo). If your cluster spawns 1,500 Kubernetes/AWS resources, your IaC bill becomes a real line item.
Pricing and TCO comparison across Terraform, OpenTofu, and Pulumi: self-hosted S3/GCS state at $0 versus managed SaaS resource-based billing in HCP Terraform and Pulumi Cloud
Managed IaC clouds bill by resource count: keeping state in S3 or GCS drops platform cost to near zero on all three engines.

The New Factor: AI Coding Agents and IaC

With tools like Claude Code, Cursor, and Copilot writing a growing share of infrastructure code, readability during human review matters more than typing speed.

  • Terraform / HCL is remarkably safe for AI generation. Because HCL has no arbitrary side effects, an LLM cannot accidentally hide an HTTP fetch or a mutable loop bug inside a resource block. Reviewing a 100-line AI-generated .tf diff takes seconds.
  • Pulumi (TypeScript / Python) benefits from compiler and type feedback. An AI agent writing Pulumi TypeScript immediately catches misspelled property names and type mismatches via tsc before even running pulumi preview. On the flip side, you must review that the agent didn’t introduce fragile async .apply() chains or pull in unnecessary packages.

Migrating Without Rebuilding Production

If you are already on Terraform and want to test Pulumi — or vice versa — you do not have to tear down production:

  1. Convert HCL to Pulumi: pulumi convert --from terraform --language typescript translates .tf files into clean TypeScript, Python, or Go scaffolding.
  2. Import existing resources: pulumi import aws:s3/bucketV2:BucketV2 my-bucket acme-artifacts-prod (just like Terraform’s import {} blocks) adopts live cloud resources into state without recreating them.
  3. Bridge state gradually: Pulumi’s terraform.state.RemoteStateReference reads outputs directly from an existing Terraform S3/GCS/HCP state file, letting new Pulumi microservices consume VPCs and subnets still managed by Terraform.

The Bottom Line: Which One Should You Pick?

Decision matrix for choosing between Terraform or OpenTofu and Pulumi based on team skills, compliance, Automation API needs, and state hosting
Pick Terraform or OpenTofu for predictable platform guardrails; pick Pulumi when software engineers own infrastructure or need the Automation API.

Choose Terraform (or OpenTofu) if:

  • A dedicated DevOps or Platform Engineering team owns shared landing zones, networking, and compliance.
  • You want strict declarative guardrails so pull requests stay boring, predictable, and easy to audit.
  • You rely on the massive ecosystem of off-the-shelf Terraform modules, Atlantis/GitLab CI workflows, or want zero vendor lock-in via OpenTofu’s MPL-2.0 license and native state encryption.

Choose Pulumi if:

  • Product engineers (writing TypeScript, Python, or Go every day) own their own cloud infrastructure and hate context-switching into HCL.
  • You need real unit testing, IDE refactoring, and shared types between application code and infrastructure.
  • You are building an Internal Developer Platform (IDP) or SaaS control plane where Pulumi’s Automation API lets your backend spin up cloud environments programmatically without shelling out to a CLI.

For most infrastructure teams, Terraform or OpenTofu remains the safest default for core cloud foundations, while Pulumi is unbeatable when infrastructure truly needs to behave like application software.

Frequently asked questions

Is Pulumi better than Terraform?

Neither is universally better; they optimize for different teams. Terraform (or OpenTofu) is usually better for dedicated platform and DevOps teams managing large multi-account landing zones where predictable pull-request diffs and strict compliance matter most. Pulumi is often better for application-heavy teams already fluent in TypeScript, Python, or Go, or when you need to embed IaC inside an internal developer portal using Pulumi's Automation API.

Does Pulumi still depend on Terraform under the hood?

For most providers, yes. While Pulumi offers native providers for AWS, Azure, Google Cloud, and Kubernetes generated directly from cloud APIs, over a hundred ecosystem providers (Cloudflare, Datadog, GitHub, and niche SaaS tools) run on top of Terraform providers via the pulumi-terraform-bridge.

How do Terraform and Pulumi pricing and licenses compare?

Terraform uses the source-available BUSL 1.1 license (with OpenTofu as the Linux Foundation MPL-2.0 fork). Pulumi's CLI and SDKs are open-source under Apache-2.0. Both let you store state for free in S3, GCS, or Azure Blob. For managed SaaS, HCP Terraform bills per resource under management (~$0.10 to ~$0.99/resource/month across tiers), while Pulumi Cloud offers a free single-user tier and credit-based team plans starting at $40/month for up to 500 resources.

Can you migrate from Terraform to Pulumi without recreating resources?

Yes. Pulumi supports converting HCL to TypeScript, Python, or Go with 'pulumi convert --from terraform', importing existing cloud resources with 'pulumi import', and even reading Terraform state outputs directly via 'terraform.state.RemoteStateReference' during a gradual migration.

ENDE