Pulumi
- Pronunciation
- PYOO-loo-mee
In short
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.
What is Pulumi?
Pulumi, first released in 2018 by the company of the same name, is an infrastructure-as-code tool. Like Terraform, it creates and updates cloud resources such as networks, databases, storage buckets and Kubernetes objects from code kept in Git. The difference is the language: instead of a configuration language, you write ordinary programs in TypeScript, JavaScript, Python, Go, C#, Java or YAML, and recent versions can also run programs written in HCL, Terraform's language.
Running pulumi up executes the program, but creating an object such as new aws.s3.Bucket(...) doesn't call the cloud directly. It registers the resource as part of the desired state; Pulumi's engine compares that with the state saved after the last deployment, shows a preview of what will be created, changed or deleted, and then makes the changes through providers, plugins for AWS, Azure, Google Cloud, Kubernetes and many more. The state is stored in Pulumi Cloud, the company's hosted service, or in a backend you manage, such as an S3 bucket. Each copy of the infrastructure, such as development and production, is a separate stack with its own configuration.
Writing infrastructure in a general-purpose language brings the tools developers already use: loops and functions instead of copied blocks, classes and packages for reusable components, autocompletion and type checking in the editor, and ordinary unit test frameworks. The flip side is that an infrastructure program can become as complicated as any other code, so it needs the same reviews and conventions.
Pulumi is most often compared with Terraform. Both are declarative in outcome: they keep state, preview changes and make real resources match the desired ones, and Pulumi can even use Terraform providers. The real differences are how you describe the infrastructure, in a general-purpose language or in HCL, and the license: Pulumi's engine is open source under Apache 2.0, while Terraform has used the Business Source License since 2023.
Key takeaways
- Pulumi is an infrastructure-as-code tool that uses general-purpose programming languages.
- Programs register resources; the engine previews and applies the differences.
- State lives in Pulumi Cloud or a self-managed backend, with one stack per environment.
- Providers connect it to AWS, Azure, Google Cloud, Kubernetes and more.
- Compared with Terraform, the main difference is the language, not the idea.
Example
import * as aws from "@pulumi/aws";
// An ordinary loop: one bucket per environment
const environments = ["staging", "production"];
export const bucketNames = environments.map((env) => {
const bucket = new aws.s3.Bucket(`assets-${env}`, {
tags: { Environment: env },
});
return bucket.bucket; // the generated bucket name
});
// pulumi preview -> shows what would be created
// pulumi up -> creates both bucketsReaders ask
What is the difference between Pulumi and Terraform?
Both are infrastructure-as-code tools that keep state, preview changes and apply them. Terraform uses its own configuration language, HCL, while Pulumi lets you describe the same infrastructure in general-purpose languages such as TypeScript or Python.
Is Pulumi free?
The Pulumi CLI and SDKs are open source under the Apache 2.0 license and free to use, with the state stored wherever you choose. Pulumi Cloud, the hosted service for state, secrets and team features, has a free tier and paid plans.
What is a Pulumi stack?
An independent instance of a Pulumi program, usually one per environment, such as development, staging and production. Each stack has its own configuration values and its own state.
See also
- TerraformDevOps & Cloud, p. 59Terraform is an infrastructure-as-code tool: you describe cloud resources in configuration files, and one command creates or updates them to match.
- Infrastructure as CodeDevOps & Cloud, p. 34Infrastructure as code is the practice of defining servers, networks, and other infrastructure in version-controlled files that tools apply automatically.
- Configuration ManagementDevOps & Cloud, p. 12Configuration management is the practice of defining the desired state of servers and software in code and using tools to apply and keep it automatically.
- TypeScriptWeb Development, p. 60TypeScript is a programming language built on JavaScript that adds static types, catching many bugs before the code runs, and compiles to plain JavaScript.
- AWSDevOps & Cloud, p. 3AWS (Amazon Web Services) is Amazon's cloud platform: more than 200 pay-as-you-go services for servers, storage, databases and much more.
- KubernetesDevOps & Cloud, p. 37Kubernetes is an open-source system that automates deploying, scaling, and managing containerized applications across a cluster of machines.
Sources
Spotted a mistake or something missing on this page?Suggest an edit