Pulumi — Infrastructure as Code in Any Programming Language
Pulumi is infrastructure as code using general-purpose languages: TypeScript, Python, Go, C#, Java, YAML. Unlike Terraform HCL, Pulumi lets you use loops, functions, classes, and real package ecosystems to describe cloud infra.
What it is
Pulumi is an infrastructure as code (IaC) platform that lets you define and manage cloud resources using general-purpose programming languages. Unlike Terraform which uses HCL (a domain-specific language), Pulumi supports TypeScript, Python, Go, C#, Java, and YAML. This means you can use loops, conditionals, functions, classes, and existing package ecosystems to manage infrastructure.
Platform engineers, DevOps teams, and developers who prefer writing infrastructure in the same language as their application code use Pulumi as their IaC tool. It supports AWS, Azure, GCP, Kubernetes, and 100+ cloud providers.
How it saves time or tokens
HCL requires learning a separate syntax with limited programming constructs. Pulumi lets you use familiar language features -- loops for creating multiple resources, functions for reusable components, type checking for catching errors before deployment, and existing package managers (npm, pip, go modules) for sharing infrastructure modules. IDE support (autocomplete, type checking, inline docs) works out of the box because you are writing in a real language.
How to use
- Install Pulumi:
brew install pulumi # macOS
curl -fsSL https://get.pulumi.com | sh
- Create a new project:
pulumi new aws-typescript # or aws-python, azure-go, etc.
- Define infrastructure in code:
import * as aws from '@pulumi/aws';
const bucket = new aws.s3.Bucket('my-bucket', {
website: { indexDocument: 'index.html' },
});
export const bucketUrl = bucket.websiteEndpoint;
- Deploy:
pulumi up # preview and deploy changes
Example
# Python example: create a VPC with subnets
import pulumi
import pulumi_aws as aws
vpc = aws.ec2.Vpc('main-vpc', cidr_block='10.0.0.0/16')
# Use a loop to create subnets across availability zones
azs = ['us-east-1a', 'us-east-1b', 'us-east-1c']
subnets = []
for i, az in enumerate(azs):
subnet = aws.ec2.Subnet(f'subnet-{az}',
vpc_id=vpc.id,
cidr_block=f'10.0.{i}.0/24',
availability_zone=az,
)
subnets.append(subnet)
pulumi.export('vpc_id', vpc.id)
pulumi.export('subnet_ids', [s.id for s in subnets])
Related on TokRepo
- DevOps Tools -- explore DevOps and infrastructure automation tools
- Automation Tools -- discover tools for deployment and workflow automation
Common pitfalls
- Pulumi state must be stored somewhere (Pulumi Cloud, S3, local file). Losing state means Pulumi cannot track existing resources. Configure a durable backend before creating production infrastructure.
- Resource naming in Pulumi is logical, not physical. Pulumi appends random suffixes to avoid naming conflicts. Use the physical name property if you need a specific resource name.
- Importing existing resources into Pulumi state requires the pulumi import command. Without importing, Pulumi creates duplicate resources instead of managing existing ones.
Frequently Asked Questions
Terraform uses HCL, a domain-specific language with limited programming constructs. Pulumi uses general-purpose languages (TypeScript, Python, Go, C#, Java) with full access to loops, conditionals, functions, and package ecosystems. Both manage cloud infrastructure with state tracking and plan/apply workflows.
Pulumi supports 100+ providers including AWS, Azure, GCP, Kubernetes, DigitalOcean, Cloudflare, Datadog, and more. Each provider is available as a language-native package (npm, pip, Go module) with full type definitions and documentation.
Yes. Pulumi provides a tf2pulumi tool that converts Terraform HCL files to Pulumi programs in your chosen language. You can also import existing Terraform state into Pulumi to manage resources created by Terraform without recreating them.
Pulumi supports multiple state backends: Pulumi Cloud (managed, free for individuals), AWS S3, Azure Blob Storage, Google Cloud Storage, or local filesystem. The state tracks which resources Pulumi manages and their current configuration.
Yes. Pulumi has a native Kubernetes provider that lets you define Kubernetes resources in TypeScript, Python, or Go. You can also deploy Helm charts, apply YAML manifests, and manage cluster resources alongside cloud infrastructure in the same program.
Citations (3)
- Pulumi GitHub— Infrastructure as code in TypeScript, Python, Go, C#, Java, and YAML
- Pulumi Documentation— Supports 100+ cloud providers
- Pulumi Get Started— State management and deployment workflows
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.