Pulumi Python SDK

3.227.0 · active · verified Wed Mar 25

Infrastructure as Code SDK for Python. Current version: 3.227.0 (Mar 2026). Requires Pulumi CLI installed separately — 'pip install pulumi' alone does nothing useful. All resource properties return Output[T] not plain values — cannot use them directly as strings/ints. Must use .apply() or Output.all() to work with output values. pulumi.export() must be at top level, not inside apply(). CLI and SDK versions should be kept in sync.

Warnings

Install

Imports

Quickstart

Pulumi Python — S3 bucket and security group with stack exports.

# 1. Install CLI: curl -fsSL https://get.pulumi.com | sh
# 2. pip install pulumi pulumi-aws
# 3. pulumi new aws-python
# 4. Edit __main__.py:

import pulumi
import pulumi_aws as aws

# Create an S3 bucket
bucket = aws.s3.Bucket(
    'my-bucket',
    acl='private',
    tags={'Environment': 'dev'}
)

# Create an EC2 security group
sg = aws.ec2.SecurityGroup(
    'web-sg',
    description='Allow HTTP',
    ingress=[aws.ec2.SecurityGroupIngressArgs(
        protocol='tcp',
        from_port=80,
        to_port=80,
        cidr_blocks=['0.0.0.0/0']
    )]
)

# Stack exports — must be at top level
pulumi.export('bucket_name', bucket.bucket)
pulumi.export('bucket_arn', bucket.arn)
pulumi.export('sg_id', sg.id)

# 5. pulumi up

view raw JSON →