mailwal

Why general-purpose languages for infrastructure?

Adam from Pulumi

Hi friend,

You know how when you're writing application code, you can:

  • Define a class or function once, import it anywhere
  • Create abstractions that bundle resources together
  • Use loops instead of copy-paste
  • pip or npm install a package someone else wrote

With Pulumi, that's how you write infrastructure:

Python
class WebService(pulumi.ComponentResource):
    def __init__(self, name, image, port, opts=None):
        super().__init__("pkg:index:WebService", name, {}, opts)
        self.lb = awsx.lb.ApplicationLoadBalancer(f"{name}-lb")
        self.service = awsx.ecs.FargateService(f"{name}-svc", {
            task_definition_args={ "container": { "name": name, "image": image, ... } }
        })
# Create two services
api = WebService("api", image="my-api:latest", port=8080)
web = WebService("web", image="my-web:latest", port=3000)

Or in TypeScript:

TypeScript
class WebService extends pulumi.ComponentResource {
  lb: awsx.lb.ApplicationLoadBalancer;
  service: awsx.ecs.FargateService;
  constructor(name: string, args: { image: string, port: number }) {
    super("pkg:index:WebService", name, {});
    this.lb = new awsx.lb.ApplicationLoadBalancer(`${name}-lb`);
    this.service = new awsx.ecs.FargateService(`${name}-svc`, {
      taskDefinitionArgs: { container: { name, image: args.image, ... } }
    });
  }
}
// Create two services
const api = new WebService("api", { image: "my-api:latest", port: 8080 });
const web = new WebService("web", { image: "my-web:latest", port: 3000 });

Works in Go, C#, and Java too.

And it's not just cloud VMs. Same patterns work for Kubernetes, Cloudflare, GitHub Actions, Datadog or whatever you're wiring together.

Try Pulumi

Cheers,

Adam

Pulumi

If you don't want to hear from me again, click here.
Pulumi Corporation, Two Union Square, 601 Union St, Pulumi Suite 1415 Seattle, WA.