Alex Spinov Terraform forces you to learn HCL. Pulumi lets you define infrastructure in TypeScript, Python, Go,...
Terraform forces you to learn HCL. Pulumi lets you define infrastructure in TypeScript, Python, Go, C#, or Java — with real loops, conditions, and abstractions.
# Terraform — custom language, limited abstractions
resource "aws_s3_bucket" "website" {
bucket = "my-website-bucket"
}
resource "aws_s3_bucket_website_configuration" "website" {
bucket = aws_s3_bucket.website.id
index_document { suffix = "index.html" }
}
// Pulumi — real TypeScript with full IDE support
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.Bucket("website", {
website: { indexDocument: "index.html" },
});
export const url = bucket.websiteEndpoint;
Same result. But TypeScript gives you: autocomplete, type checking, refactoring tools, loops, functions, npm packages.
npm install -g @pulumi/pulumi
pulumi new aws-typescript
# Creates project, installs deps, configures state
// Create 3 servers with Pulumi
const servers = [1, 2, 3].map(i =>
new aws.ec2.Instance(`server-${i}`, {
instanceType: "t3.micro",
ami: "ami-0abcdef1234567890",
tags: { Name: `web-${i}` },
})
);
Try doing this in Terraform — you need count or for_each with limited capabilities.
const isProduction = pulumi.getStack() === "production";
const db = new aws.rds.Instance("database", {
instanceClass: isProduction ? "db.r5.xlarge" : "db.t3.micro",
multiAz: isProduction,
backupRetentionPeriod: isProduction ? 30 : 1,
});
class WebApp extends pulumi.ComponentResource {
public url: pulumi.Output<string>;
constructor(name: string, args: { domain: string; dockerImage: string }) {
super("custom:WebApp", name);
const cluster = new aws.ecs.Cluster(`${name}-cluster`, {}, { parent: this });
const service = new aws.ecs.FargateService(`${name}-service`, {
cluster: cluster.arn,
taskDefinition: /* ... */,
}, { parent: this });
this.url = pulumi.interpolate`https://${args.domain}`;
}
}
// Use it like any TypeScript class
const app = new WebApp("my-app", {
domain: "app.example.com",
dockerImage: "my-registry/app:latest",
});
Pulumi supports 150+ providers:
import * as aws from "@pulumi/aws";
import * as gcp from "@pulumi/gcp";
import * as azure from "@pulumi/azure-native";
import * as k8s from "@pulumi/kubernetes";
import * as cloudflare from "@pulumi/cloudflare";
import * as vercel from "@pulumiverse/vercel";
pulumi ai "create an S3 bucket with CloudFront CDN and Route53 DNS"
# Generates complete TypeScript code
Need infrastructure automation? I build DevOps tools and data pipelines. Email spinov001@gmail.com or check my Apify tools.