Skip to main content
Python is the dominant language in data engineering, machine learning infrastructure, and much of the cloud operations world. Teams already running Python-heavy stacks in Pulumi can use the same language across their entire platform by setting runtime = "python" in ubx.iac. ubx generates a __main__.py and a requirements.txt — a standard Python Pulumi project that any Python developer can read, understand, and extend. The .iac source is byte-for-byte identical to the TypeScript example in tutorial 42 — runtime is the only difference. This is the multi-runtime promise: write your infrastructure once in .iac, choose your execution language based on your team’s preferences and existing tooling, not on what the IaC tool supports.

What you’ll learn

  • What Python output ubx generates from a .iac stack
  • How runtime = "python" selects the Python compiler target
  • How the generated Python maps .iac constructs to Pulumi Python idioms

Why this matters

Python runtime is the right choice for teams where Python is the primary language — data pipelines, ML platforms, analytics infrastructure. Running Python Pulumi programs means your IaC lives in the same language as your data code, with the same linting, the same CI tooling, the same developer familiarity.

The source code

# Identical source to tutorial 42 — only ubx.iac changes.
unit "aws_s3_bucket_v2" "store" {
  bucket = "myapp-${input.env}-store"
}

What ubx generates

# Generated by ubx — do not edit
import pulumi
import pulumi_aws as aws

config = pulumi.Config()
env = config.get("env") or "dev"

store = aws.s3.BucketV2("store",
    bucket=f"myapp-{env}-store",
)

pulumi.export("bucket_name", store.bucket)

TypeScript vs Python — side by side

The same bucket, two languages:
// TypeScript (tutorial 42)
const store = new aws.s3.BucketV2("store", { bucket: `myapp-${env}-store` });
export const bucketName = store.bucket;
# Python (this tutorial)
store = aws.s3.BucketV2("store", bucket=f"myapp-{env}-store")
pulumi.export("bucket_name", store.bucket)
Same semantics, idiomatic syntax for each language. ubx generates the right idioms — not a mechanical translation.

Run it

ubx validate
ubx plan    # requires AWS credentials
ubx apply

What you learned

runtime = "python" generates __main__.py + requirements.txt + Pulumi.yaml
The .iac source is identical to the TypeScript version — only ubx.iac changes
ubx generates idiomatic Python, not a mechanical TypeScript translation

Next steps

Go runtime

The same source compiled to Go

TypeScript runtime

Compare with the TypeScript output