Linuxguide

Pulumi – IaC mit TypeScript und Python 2025

Infrastruktur in echten Programmiersprachen definieren

S
SeeColors IT
11. Juni 20264 Min. Lesezeit132 Aufrufe

Pulumi vs Terraform

Terraform/OpenTofu:
  Sprache: HCL (HashiCorp Configuration Language)
  Lernkurve: einfach fuer HCL
  Loops: fuer_each, count (begrenzt)
  Community: riesig, 1000+ Provider
  Reife: sehr ausgereift

Pulumi:
  Sprachen: TypeScript, Python, Go, C#, Java, YAML
  Lernkurve: Kennt man schon Programmieren → direkt
  Loops: echte Schleifen (for, while, map)
  Tests: Unit Tests mit normalen Test-Frameworks
  Dynamik: Datenbank-Query im IaC-Code moeglich!

Fazit: Terraform fuer einfache Infra, Pulumi wenn
komplexe Logik oder bekannte Programmiersprache

Pulumi installieren

# Linux/macOS
curl -fsSL https://get.pulumi.com | sh

# macOS
brew install pulumi

# Version
pulumi version

# Backend: Pulumi Cloud (kostenlos bis 1 Projekt)
# oder S3/Azure Blob (self-managed)
pulumi login s3://mein-pulumi-state-bucket

Erstes Pulumi-Projekt (TypeScript)

# Neues Projekt erstellen
mkdir meine-infra && cd meine-infra
pulumi new aws-typescript

# Struktur:
# index.ts        → Haupt-Infrastruktur-Code
# Pulumi.yaml     → Projektmetadaten
# Pulumi.dev.yaml → Stack-Konfiguration
# package.json    → Node.js-Abhaengigkeiten
// index.ts
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

// VPC und ECS Fargate Cluster
const vpc = new awsx.ec2.Vpc("main-vpc", {
    numberOfAvailabilityZones: 2,
    subnetSpecs: [
        { type: "Public" },
        { type: "Private" }
    ]
});

const cluster = new aws.ecs.Cluster("app-cluster");

// Container mit Load Balancer (in 3 Zeilen!)
const service = new awsx.ecs.FargateService("meine-app", {
    cluster: cluster.arn,
    assignPublicIp: false,
    taskDefinitionArgs: {
        containers: {
            app: {
                image: "nginx:latest",
                memory: 128,
                portMappings: [{ containerPort: 80, protocol: "tcp" }]
            }
        }
    }
});

export const url = service.loadBalancer.dnsName;

Pulumi mit Azure

# Azure-Stack erstellen
pulumi new azure-typescript

az login  # Azure-Authentifizierung
// index.ts - Azure
import * as azure from "@pulumi/azure-native";

const rg = new azure.resources.ResourceGroup("meine-app-rg", {
    location: "germanywestcentral"
});

// Dynamisch: 3 VMs mit Schleife erstellen!
const vms = [1, 2, 3].map(i =>
    new azure.compute.VirtualMachine(`vm-${i}`, {
        resourceGroupName: rg.name,
        location: rg.location,
        vmSize: "Standard_B2s",
        // ...
    })
);

export const vmNames = vms.map(vm => vm.name);

FAQ

Kann ich bestehende Terraform-Ressourcen zu Pulumi migrieren?
Ja, mit pulumi convert --from terraform. Konvertiert .tf-Dateien zu Pulumi-Konfiguration (TypeScript, Python, etc.). State kann auch importiert werden.

Fazit

Pulumi ist die beste Wahl wenn IaC-Code Teil einer echten Applikation werden soll: echte Programmiersprachen, Tests und volle Bibliotheks-Unterstuetzung.

IaC und DevOps fuer KMU in Heidelberg, Mannheim und der Rhein-Neckar-Region. Beratung anfragen.

Artikel teilen

War dieser Artikel hilfreich?

Dein Feedback hilft uns, bessere Inhalte zu erstellen.

Kommentar hinterlassen

Verwandte Artikel