What is Pulumi?
Pulumi lets you define cloud infrastructure using real programming languages — TypeScript, Python, Go, C#, Java — instead of YAML or HCL. You get loops, conditionals, functions, type checking, and IDE autocomplete for your infrastructure.
The open-source engine is completely free.
Quick Start
curl -fsSL https://get.pulumi.com | sh
pulumi new aws-typescript
pulumi up
Define Infrastructure in TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
// S3 bucket with website hosting
const bucket = new aws.s3.Bucket("my-site", {
website: {
indexDocument: "index.html",
errorDocument: "error.html",
},
});
// Upload files
new aws.s3.BucketObject("index", {
bucket: bucket.id,
key: "index.html",
content: "<h1>Hello Pulumi!</h1>",
contentType: "text/html",
});
// CloudFront CDN
const cdn = new aws.cloudfront.Distribution("cdn", {
origins: [{
domainName: bucket.websiteEndpoint,
originId: bucket.arn,
customOriginConfig: {
httpPort: 80,
httpsPort: 443,
originProtocolPolicy: "http-only",
originSslProtocols: ["TLSv1.2"],
},
}],
enabled: true,
defaultCacheBehavior: {
targetOriginId: bucket.arn,
viewerProtocolPolicy: "redirect-to-https",
allowedMethods: ["GET", "HEAD"],
cachedMethods: ["GET", "HEAD"],
forwardedValues: { queryString: false, cookies: { forward: "none" } },
},
restrictions: { geoRestriction: { restrictionType: "none" } },
viewerCertificate: { cloudfrontDefaultCertificate: true },
});
export const url = pulumi.interpolate`https://${cdn.domainName}`;
Automation API (Programmatic Control)
Pulumi's Automation API lets you manage stacks from your own code:
import { LocalWorkspace } from "@pulumi/pulumi/automation";
async function deploy() {
const stack = await LocalWorkspace.createOrSelectStack({
stackName: "production",
projectName: "my-infra",
program: async () => {
const bucket = new aws.s3.Bucket("my-bucket");
return { bucketName: bucket.id };
},
});
await stack.setConfig("aws:region", { value: "us-east-1" });
const result = await stack.up({ onOutput: console.log });
console.log(`Bucket: ${result.outputs.bucketName.value}`);
}
async function destroy() {
const stack = await LocalWorkspace.selectStack({
stackName: "production",
projectName: "my-infra",
program: async () => {},
});
await stack.destroy({ onOutput: console.log });
}
Build internal developer platforms, self-service portals, or CI/CD pipelines with full infrastructure control.
Component Resources (Reusable Modules)
class StaticSite extends pulumi.ComponentResource {
public readonly url: pulumi.Output<string>;
constructor(name: string, args: { path: string; domain?: string }, opts?: pulumi.ComponentResourceOptions) {
super("custom:StaticSite", name, {}, opts);
const bucket = new aws.s3.Bucket(`${name}-bucket`, {
website: { indexDocument: "index.html" },
}, { parent: this });
// Upload all files from path
// ... (sync logic)
this.url = bucket.websiteEndpoint;
this.registerOutputs({ url: this.url });
}
}
// Use it like any other resource
const site = new StaticSite("docs", { path: "./dist" });
export const siteUrl = site.url;
Multi-Cloud
import * as gcp from "@pulumi/gcp";
import * as azure from "@pulumi/azure-native";
// Same language, any cloud
const gcpBucket = new gcp.storage.Bucket("gcp-bucket");
const azureBlob = new azure.storage.StorageAccount("azure-storage", {
resourceGroupName: "my-rg",
sku: { name: "Standard_LRS" },
kind: "StorageV2",
});
Pulumi vs Terraform
| Feature | Pulumi | Terraform |
|---|---|---|
| Language | TypeScript/Python/Go | HCL |
| IDE Support | Full (autocomplete, types) | Limited |
| Testing | Standard test frameworks | Terratest |
| Loops/Conditions | Native language | count/for_each |
| State | Free (Pulumi Cloud) | Terraform Cloud ($) |
| Reuse | npm/pip packages | Modules (HCL) |
Need infrastructure automation or cloud architecture help?
📧 spinov001@gmail.com
🔧 My tools on Apify Store
Pulumi or Terraform — which do you prefer? Comment below!
Top comments (0)