Pulumi Packages

Build and reuse cloud infrastructure as code

Pulumi Packages give you the building blocks to easily build and deploy cloud infrastructure with TypeScript/JavaScript, Python, Go, and C#. Provision resources from the top clouds and SaaS providers to build cloud infrastructure that meets your needs. For popular architectures like Kubernetes or serverless, use Pulumi components to get to production faster than ever.

A package for every cloud and architecture

Providers give you direct access to cloud resources

Use over 60 providers to build your infrastructure from scratch with cloud and SaaS integrations. Pulumi Native Providers give you the most comprehensive resource coverage of AWS, Azure, Google Cloud, and Kubernetes with same-day access to new features.

import * as aws from "@pulumi/aws";
import * as pulumi from "@pulumi/pulumi";

// Get the id for the latest Amazon Linux AMI
const ami = aws.ec2.getAmi({
    filters: [
        { name: "name", values: ["amzn-ami-hvm-*-x86_64-ebs"] },
    ],
    owners: ["137112412989"], // Amazon
    mostRecent: true,
}).then(result => result.id);

// create a new security group for port 80
const group = new aws.ec2.SecurityGroup("web-secgrp", {
    ingress: [
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

const server = new aws.ec2.Instance("web-server-www", {
    tags: { "Name": "web-server-www" },
    instanceType: aws.ec2.InstanceType.T2_Micro, // t2.micro is available in the AWS free tier
    vpcSecurityGroupIds: [ group.id ], // reference the group object above
    ami: ami,
});

export const publicIp = server.publicIp;
export const publicHostName = server.publicDns;
import pulumi
import pulumi_aws as aws

size = 't2.micro'

ami = aws.ec2.get_ami(most_recent=True,
                owners=["137112412989"],
                filters=[aws.GetAmiFilterArgs(name="name", values=["amzn-ami-hvm-*"])])

group = aws.ec2.SecurityGroup('web-secgrp',
    description='Enable HTTP access',
    ingress=[aws.ec2.SecurityGroupIngressArgs(
        protocol='tcp',
        from_port=80,
        to_port=80,
        cidr_blocks=['0.0.0.0/0'],
    )])

server = aws.ec2.Instance('web-server-www',
    instance_type=size,
    vpc_security_group_ids=[group.id],
    ami=ami.id)

pulumi.export('public_ip', server.public_ip)
pulumi.export('public_dns', server.public_dns)
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        // Create a new security group for port 80.
        group, err := ec2.NewSecurityGroup(ctx, "web-secgrp", &ec2.SecurityGroupArgs{
            Ingress: ec2.SecurityGroupIngressArray{
                ec2.SecurityGroupIngressArgs{
                    Protocol:   pulumi.String("tcp"),
                    FromPort:   pulumi.Int(80),
                    ToPort:     pulumi.Int(80),
                    CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
                },
            },
        })
        if err != nil {
            return err
        }

        // Get the ID for the latest Amazon Linux AMI.
        mostRecent := true
        ami, err := ec2.LookupAmi(ctx, &ec2.LookupAmiArgs{
            Filters: []ec2.GetAmiFilter{
                {
                    Name:   "name",
                    Values: []string{"amzn-ami-hvm-*-x86_64-ebs"},
                },
            },
            Owners:     []string{"137112412989"},
            MostRecent: &mostRecent,
        })
        if err != nil {
            return err
        }

        // Create a simple web server using the startup script for the instance.
        srv, err := ec2.NewInstance(ctx, "web-server-www", &ec2.InstanceArgs{
            Tags:                pulumi.StringMap{"Name": pulumi.String("web-server-www")},
            InstanceType:        pulumi.String("t2.micro"), // t2.micro is available in the AWS free tier.
            VpcSecurityGroupIds: pulumi.StringArray{group.ID()},
            Ami:                 pulumi.String(ami.Id),
        })

        // Export the resulting server's IP address and DNS name.
        ctx.Export("publicIp", srv.PublicIp)
        ctx.Export("publicHostName", srv.PublicDns)
        return nil
    })
}
using Pulumi;
using Pulumi.Aws;
using Pulumi.Aws.Ec2;
using Pulumi.Aws.Ec2.Inputs;
using Pulumi.Aws.Inputs;

class WebServerStack : Stack
{
    public WebServerStack()
    {
        var ami = Output.Create(Pulumi.Aws.Ec2.GetAmi.InvokeAsync(new Pulumi.Aws.Ec2.GetAmiArgs
        {
            MostRecent = true,
            Owners = {"137112412989"},
            Filters = {new Pulumi.Aws.Ec2.Inputs.GetAmiFilterArgs {Name = "name", Values = {"amzn-ami-hvm-*"}}}
        }));

        var group = new SecurityGroup("web-secgrp", new SecurityGroupArgs
        {
            Description = "Enable HTTP access",
            Ingress =
            {
                new SecurityGroupIngressArgs
                {
                    Protocol = "tcp",
                    FromPort = 80,
                    ToPort = 80,
                    CidrBlocks = {"0.0.0.0/0"}
                }
            }
        });

        var server = new Instance("web-server-www", new InstanceArgs
        {
            InstanceType = Size,
            VpcSecurityGroupIds = {group.Id},
            Ami = ami.Apply(a => a.Id)
        });

        this.PublicIp = server.PublicIp;
        this.PublicDns = server.PublicDns;
    }

    [Output] public Output<string> PublicIp { get; set; }

    [Output] public Output<string> PublicDns { get; set; }

    private const string Size = "t2.micro";
}
package webserver;

import com.pulumi.Context;
import com.pulumi.Exports;
import com.pulumi.Pulumi;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.Instance;
import com.pulumi.aws.ec2.InstanceArgs;
import com.pulumi.aws.ec2.SecurityGroup;
import com.pulumi.aws.ec2.SecurityGroupArgs;
import com.pulumi.aws.ec2.inputs.GetAmiArgs;
import com.pulumi.aws.ec2.inputs.GetAmiFilter;
import com.pulumi.aws.ec2.inputs.SecurityGroupIngressArgs;
import com.pulumi.aws.ec2.outputs.GetAmiResult;
import com.pulumi.core.Output;

import java.util.List;
import java.util.Map;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static Exports stack(Context ctx) {
        final var ami = Ec2Functions.getAmi(GetAmiArgs.builder()
                .filters(new GetAmiFilter("name", List.of("amzn-ami-hvm-*-x86_64-ebs")))
                .owners("137112412989")
                .mostRecent(true)
                .build()
        ).thenApply(GetAmiResult::id);

        final var group = new SecurityGroup("web-secgrp", SecurityGroupArgs.builder()
                .ingress(SecurityGroupIngressArgs.builder()
                        .protocol("tcp")
                        .fromPort(80)
                        .toPort(80)
                        .cidrBlocks("0.0.0.0/0")
                        .build())
                .build()
        );

        // (optional) create a simple web server using the startup
        // script for the instance

        final var userData =
                "#!/bin/bash\n" +
                        "echo \"Hello, World!\" > index.html\n" +
                        "nohup python -m SimpleHTTPServer 80 &";

        final var server = new Instance("web-server-www", InstanceArgs.builder()
                .tags(Map.of("Name", "web-server-www"))
                .instanceType(Output.ofRight(com.pulumi.aws.ec2.enums.InstanceType.T2_Micro))
                .vpcSecurityGroupIds(group.getId().applyValue(List::of))
                .ami(Output.of(ami))
                .userData(userData)
                .build()
        );

        ctx.export("publicIp", server.publicIp());
        ctx.export("publicHostName", server.publicDns());
        return ctx.exports();
    }
}
name: webserver
runtime: yaml
description: Basic example of an AWS web server accessible over HTTP
configuration:
InstanceType:
    type: String
    default: t3.micro
variables:
    ec2ami:
        Fn::Invoke:
        Function: aws:getAmi
        Arguments:
            filters:
              - name: name
                values: ["amzn-ami-hvm-*-x86_64-ebs"]
            owners: ["137112412989"]
            mostRecent: true
        Return: id
resources:
    WebSecGrp:
        type: aws:ec2:SecurityGroup
        properties:
        ingress:
            - protocol: tcp
              fromPort: 80
              toPort: 80
              cidrBlocks: ["0.0.0.0/0"]
    WebServer:
        type: aws:ec2:Instance
        properties:
        instanceType: ${InstanceType}
        ami: ${ec2ami}
        userData: |-
            #!/bin/bash
            echo 'Hello, World from ${WebSecGrp.arn}!' > index.html
            nohup python -m SimpleHTTPServer 80 &            
        vpcSecurityGroupIds:
            - ${WebSecGrp}
outputs:
    PublicIp: ${WebServer.publicIp}
    PublicHostName: ${WebServer.publicDns}

Components give you production-ready cloud architectures

Build production-quality cloud architectures faster and smarter with components. These higher-level building blocks come with best practices and sensible defaults built in so you can spend less time on configuration and more time on building applications.

import * as eks from "@pulumi/eks";

// Create an EKS cluster.
const cluster = new eks.Cluster("cluster", {
    instanceType: "t2.medium",
    desiredCapacity: 2,
    minSize: 1,
    maxSize: 2,
});

// Export the cluster's kubeconfig.
export const kubeconfig = cluster.kubeconfig;
import pulumi
import pulumi_eks as eks

# Create an EKS cluster.
cluster = eks.Cluster(
    "cluster",
    instance_type="t2.medium",
    desired_capacity=2,
    min_size=1,
    max_size=2,
)

# Export the cluster's kubeconfig.
pulumi.export("kubeconfig", cluster.kubeconfig)
package main

import (
    "github.com/pulumi/pulumi-eks/sdk/go/eks/cluster"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
    // Create an EKS cluster.
    cluster, err := cluster.NewCluster(ctx, "cluster",
        cluster.ClusterArgs{
            InstanceType:    pulumi.String("t2.medium"),
            DesiredCapacity: pulumi.Int(2),
            MinSize:         pulumi.Int(1),
            MaxSize:         pulumi.Int(2),
        },
    )
    if err != nil {
        return err
    }

    // Export the cluster's kubeconfig.
    ctx.Export("kubeconfig", cluster.Kubeconfig)

    return nil
    })
}
using System;
using System.Threading.Tasks;
using Pulumi;
using Pulumi.Eks.Cluster;

class EksStack : Stack
{
    public EksStack()
    {
        // Create an EKS cluster.
        var cluster = new Cluster("cluster", new ClusterArgs
        {
            InstanceType = "t2.medium",
            DesiredCapacity = 2,
            MinSize = 1,
            MaxSize = 2,
        });

        // Export the cluster's kubeconfig.
        this.Kubeconfig = cluster.Kubeconfig;
    }

    [Output("kubeconfig")]
    public Output<string> Kubeconfig { get; set; }
}

class Program
{
    static Task<int> Main(string[] args) => Deployment.RunAsync<EksStack>();
}
package com.pulumi.example.eks;

import com.pulumi.Context;
import com.pulumi.Exports;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.eks.Cluster;
import com.pulumi.eks.ClusterArgs;

import java.util.stream.Collectors;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    private static Exports stack(Context ctx) {
        var cluster = new Cluster("my-cluster", ClusterArgs.builder()
                .instanceType("t2.micro")
                .desiredCapacity(2)
                .minSize(1)
                .maxSize(2)
                .build());

        ctx.export("kubeconfig", cluster.kubeconfig());
        return ctx.exports();
    }
}
name: aws-eks
runtime: yaml
description: An EKS cluster
resources:
    cluster:
        type: eks:Cluster
        properties:
            instanceType: "t2.medium"
            desiredCapacity: 2
            minSize: 1
            maxSize: 2
outputs:
    kubeconfig: ${cluster.kubeconfig}

Benefits

Use your favorite languages

Start building infrastructure just by installing a Go module or a NuGet, npm, or Python package. Create your own packages in every language by authoring in just one language.

Get started faster

Find everything you need in each package to start building cloud infrastructure and applications, including SDKs, how-to guides, and API references with hundreds of examples.

Build faster and smarter

Don’t reinvent the wheel. Use or create infrastructure abstractions that encapsulate cloud architectures and best practices with Pulumi components in your favorite languages.

Share and track infrastructure code

Distribute your infrastructure code through package managers and artifactories. Share and reuse code with versioning, dependency management, and auditing.

Case Studies

Pulumi supercharged our infrastructure team by helping us create reusable building blocks that developers can leverage... This empowered our developer teams to self-provision resources and ship new capabilities faster without having to wait for the infrastructure team to deploy new resources on their behalf.

Igor Shapiro

Principal Engineer at Lemonade

A key benefit of Pulumi is that it allows us to modularize our cloud infrastructure as reusable Python components that enable our developer teams to build faster and more independently.

Danny Zalkind

DevOps Group Manager at Skai

Our developers needed a robust platform for managing our complex infrastructure, and it needed to be fast, modular, and testable. We now have more reliable releases and a significantly better developer experience as a result of adopting Pulumi.

Austin Byers

Principal Platform Engineer at Panther Labs

Panther logo White

Getting started

Browse all Packages in the Registry

View the API docs and examples of all the supported providers and components in the Pulumi ecosystem.

Go to the registry

Build Your Own Packages

Learn how to get started building and publishing your own Pulumi Packages.

Read the docs