Internative Logo

What Is Pulumi? Infrastructure as Code in Real Languages

What Is Pulumi? Infrastructure as Code in Real Languages

Creating cloud infrastructure by clicking through a console works once. It does not work when the same network, database and cluster have to exist in development, staging and production, when changes need review, or when someone has to rebuild everything after an incident. Infrastructure as code (IaC) solves that by describing infrastructure in files that live in version control. Pulumi takes that idea one step further: instead of a special configuration language, you write the infrastructure in TypeScript, Python, Go, C# or Java, the same languages your applications already use.

This article explains what Pulumi is, how it turns a program into cloud resources, where it fits, when another tool is the better choice, and how it compares with Terraform and the cloud providers' own tools.

What is Pulumi?

Pulumi is an open-source infrastructure as code platform. You describe cloud resources, such as virtual networks, databases, storage buckets, Kubernetes clusters or DNS records, as objects in a general-purpose programming language, and Pulumi creates, updates or deletes them so that the real infrastructure matches the program. It supports TypeScript and JavaScript, Python, Go, .NET languages such as C#, Java, and YAML for simple cases.

Pulumi Corporation was founded in Seattle in 2017 by Joe Duffy and Eric Rudder, with Luke Hoban on the founding team, all veterans of developer tools. The project was launched as open source on 18 June 2018 under the Apache 2.0 licence, and Pulumi 1.0, the first release declared stable, followed on 5 September 2019. Alongside the open-source engine the company runs Pulumi Cloud, a managed service for state, secrets, policies and team workflows.

How Pulumi works

A program declares the desired state. A Pulumi program creates resource objects, for example a storage bucket with versioning enabled and a database that only accepts connections from a private network. Running the program does not call cloud APIs directly; it registers those resources with the Pulumi engine.

The engine compares and plans. The engine compares the declared resources with the last recorded state and works out what must be created, changed or removed. pulumi preview shows that plan before anything happens, and pulumi up applies it, in the right order, because Pulumi tracks the dependencies between resources.

State lives in a backend. Pulumi records what it manages in a state file, stored either in Pulumi Cloud or in a backend you run yourself, such as an S3 bucket, Azure Blob Storage, Google Cloud Storage or a local directory. Secrets in configuration and state are encrypted.

Providers talk to the clouds. Providers translate resources into API calls for AWS, Azure, Google Cloud, Kubernetes and many other services. Some are native to Pulumi, others are built on Terraform providers, and any Terraform or OpenTofu provider can be used directly.

Stacks separate environments. A stack is one deployed instance of a program, such as dev, staging or prod, each with its own configuration and state, so the same code produces each environment.

Key features

  • Real programming languages with loops, functions, classes, package managers, IDE autocompletion and type checking.
  • Unit and integration tests written with the language's normal test frameworks.
  • Component resources that wrap a group of resources, such as a standard service with its load balancer and alarms, into one reusable package.
  • Policy as code that checks plans against rules, such as "no public storage buckets", before they are applied.
  • Automation API, which lets other programs run Pulumi, for example a self-service portal that creates environments on demand.
  • Import and conversion of existing cloud resources and of Terraform code, so teams can adopt Pulumi gradually.
  • Pulumi ESC for managing secrets and configuration across environments and tools.

Where Pulumi is used

  • Cloud foundations: networks, identity, databases and clusters for AWS, Azure and Google Cloud, often across several accounts.
  • Kubernetes platforms, where the same program creates the cluster and deploys the applications onto it.
  • Platform engineering, where a platform team publishes components and developers create approved infrastructure without writing it from scratch.
  • Temporary environments created for each pull request or test run and destroyed afterwards.
  • SaaS provisioning, where each new customer or tenant gets its own resources created by code.

When to choose Pulumi, and when not to

Choose Pulumi when:

  • Infrastructure logic is complex: many similar resources, conditions, generated configuration or shared building blocks.
  • Developers will write and review infrastructure changes, and you want them in a language they already know, such as TypeScript or Python.
  • You want to test infrastructure code like application code and reuse it as packages.
  • Infrastructure has to be created from inside another application, through the Automation API.

Look elsewhere when:

  • The team already has a large, working Terraform codebase and the skills to maintain it. Migrating brings little unless there is a clear pain point.
  • You want infrastructure to stay deliberately simple and declarative. A general-purpose language makes it easy to write clever code that is hard to review.
  • The whole estate is on one cloud and the team prefers that cloud's native tool, such as AWS CloudFormation or Azure Bicep.
  • The task is configuring servers rather than creating them. Installing packages and editing files on machines is configuration management, where Ansible fits better.

Pulumi and its alternatives

ToolLanguageScopeBest fit
PulumiTypeScript, Python, Go, C#, Java, YAMLMulti-cloud IaCDeveloper-led teams, complex logic
TerraformHCLMulti-cloud IaCLarge existing ecosystems, ops-led teams
OpenTofuHCLOpen-source fork of TerraformTeams that want Terraform under an open licence
AWS CDKTypeScript, Python, Java, C#, GoAWS only, via CloudFormationAWS-only estates
Azure BicepBicep DSLAzure onlyAzure-only estates

The main comparison is Pulumi vs Terraform. Both are declarative engines that compare desired and actual state; the difference is how you describe that state. Terraform uses HCL, a configuration language that is easy to read and limited on purpose. Pulumi uses general-purpose languages, which give more power and better tooling at the cost of more freedom to over-engineer. After HashiCorp moved Terraform to the Business Source License in 2023, the community created OpenTofu as an open-source fork, which made licensing part of the decision for some teams. Pulumi can use Terraform and OpenTofu providers, so provider coverage is rarely the deciding factor.

How we use Pulumi at Internative

We use Pulumi on projects that need complex infrastructure logic and close integration with application code. It lets us manage infrastructure in the same languages and with the same practices as the software systems we build, including reviews, tests and shared packages. We describe how infrastructure code fits into a delivery process in DevOps and CI/CD: continuous improvement in software development.

If you are setting up a new cloud environment or bringing existing infrastructure under code, our DevOps services and cloud architecture and migration teams can help you choose the right tool for your team.

Frequently asked questions

What is Pulumi used for?

Pulumi is used to create and manage cloud infrastructure with code: networks, databases, storage, Kubernetes clusters, DNS and more, on AWS, Azure, Google Cloud and other providers. Teams use it to keep environments consistent, review infrastructure changes like code and automate provisioning.

Is Pulumi open source?

Yes. The Pulumi engine, CLI, language SDKs and providers are open source under the Apache 2.0 licence. Pulumi Cloud, the managed service for state, secrets, policies and team features, is a commercial product, but it is optional: state can be kept in your own storage.

Can I use Pulumi for free?

Yes. The open-source tool is free, including with a self-managed state backend such as an S3 bucket. Pulumi Cloud offers a free tier for individuals and paid plans for teams and enterprises that need collaboration, access control and governance features.

Can Pulumi use Terraform providers?

Yes. Many Pulumi providers are built on top of Terraform providers, and Pulumi can also use any Terraform or OpenTofu provider directly by generating an SDK for it. Pulumi can also convert existing Terraform code into a Pulumi program.

Related services

Where this topic becomes an engagement.

Keep reading

The articles that follow this one.