Skip to main content

Side by side

TerraformvsPulumi

What is the difference between Terraform and Pulumi?

Updated 3 min read8 differences

In short

Terraform describes infrastructure in its own configuration language, HCL; Pulumi describes the same resources in languages such as TypeScript or Python.

Terraform

Terraform is an infrastructure-as-code tool: you describe cloud resources in configuration files, and one command creates or updates them to match.

Read the page on Terraform

Pulumi

Pulumi is an open-source infrastructure-as-code tool that defines cloud resources in general-purpose languages such as TypeScript, Python, Go, C# or Java.

Read the page on Pulumi

Terraform and Pulumi compared

AspectTerraformPulumi
LanguageHCL, a declarative configuration languageTypeScript, JavaScript, Python, Go, C#, Java or YAML
ReuseModules, many of them from the public Terraform RegistryFunctions, classes and packages of the chosen language
Preview and applyterraform plan, then terraform applypulumi preview, then pulumi up
StateA state file, usually in remote storage or HCP TerraformPulumi Cloud or a backend you manage, such as an S3 bucket
TestingBuilt-in terraform test and checks on the planThe usual unit test frameworks of each language
EcosystemThe largest community, with many modules and examplesSmaller, but able to use Terraform providers
LicenseBusiness Source License since 2023; OpenTofu is the open-source forkOpen-source engine under Apache 2.0; Pulumi Cloud has free and paid plans
Best forTeams that want one simple, widely known languageDeveloper teams that want infrastructure in their application's language

The difference, explained

Terraform, released by HashiCorp in 2014, and Pulumi, first released in 2018, are both infrastructure-as-code tools: they create and update cloud resources such as networks, databases, storage buckets and Kubernetes objects from code kept in Git. Terraform uses HCL, HashiCorp Configuration Language, a declarative language made for describing infrastructure. Pulumi lets you write ordinary programs in TypeScript, JavaScript, Python, Go, C#, Java or YAML.

The real difference is how you describe the infrastructure, not how it is managed. Both keep state about the resources they manage, preview changes with terraform plan or pulumi preview, apply them with terraform apply or pulumi up, and reach clouds through providers; Pulumi can even use Terraform providers. HCL keeps a configuration simple and predictable to read, while a general-purpose language brings loops, functions, classes, packages, type checking and ordinary unit tests.

Licensing and ecosystem differ too. Terraform moved to the source-available Business Source License in 2023, and the community fork OpenTofu keeps an open-source version that works in much the same way; Pulumi's engine is open source under Apache 2.0. Terraform has the larger community, with more modules, examples and engineers who already know it, while Pulumi appeals to developers who want infrastructure in the same language as their application.

A common misconception is that Pulumi is imperative because you write it in a programming language. The program only registers the desired resources; Pulumi's engine compares them with the saved state and applies the differences, just as Terraform does. Another is that a general-purpose language always means simpler infrastructure: it removes repetition, but an infrastructure program can grow as complicated as any other code and needs the same reviews and conventions.

Which one should you use?

Choose Terraform when…

  • Your team wants a simple language that reads the same in every project.
  • You rely on existing modules, examples and engineers who already know HCL.
  • Configurations are mostly plain lists of resources without much logic.
  • Hiring and onboarding matter, since HCL is the most widely known infrastructure-as-code language.

Choose Pulumi when…

  • The developers who write the application also own its infrastructure.
  • You need loops, conditions and reusable components beyond what HCL handles comfortably.
  • You want type checking, autocompletion and unit tests from your usual language.
  • You want an open-source engine under the Apache 2.0 license.

The same two storage buckets in Terraform and in Pulumi

Terraformtext
# Terraform (HCL): two buckets, one per environment
variable "environments" {
  default = ["staging", "production"]
}

resource "aws_s3_bucket" "assets" {
  for_each = toset(var.environments)
  bucket   = "example-assets-${each.key}"
  tags     = { Environment = each.key }
}
# terraform plan, then terraform apply
Pulumitext
// Pulumi (TypeScript): the same buckets with an ordinary loop
import * as aws from "@pulumi/aws";

const environments = ["staging", "production"];

for (const env of environments) {
  new aws.s3.Bucket(`assets-${env}`, {
    bucket: `example-assets-${env}`,
    tags: { Environment: env },
  });
}
// pulumi preview, then pulumi up

Readers ask

Is Pulumi better than Terraform?

Neither is better in general. Terraform has the larger ecosystem and a simple, widely known language; Pulumi suits teams that want to write infrastructure in a general-purpose language, with its tools and tests.

Can Pulumi use Terraform providers and code?

Yes. Pulumi can use Terraform providers to reach platforms it doesn't cover natively, and it has tools to convert HCL configurations into Pulumi programs. Recent versions can also run programs written in HCL.

What is OpenTofu?

An open-source fork of Terraform, created in 2023 after HashiCorp moved Terraform to the Business Source License. It works in much the same way, with HCL and the same providers, and is developed as an open community project.

More

Settings