Fork me on GitHub

Programs

To get code to the cloud, you write Pulumi programs in your language of choice.

Pulumi currently supports JavaScript and TypeScript (using Node.js), Python, and Go. More languages are on their way!

Pulumi programs are just like normal programs, except for a few important details:

  • You run them using the pulumi CLI instead of invoking them directly
  • They describe cloud resources, like containers, functions, and databases, that Pulumi will provision
  • The result is a plan that may be previewed before asking Pulumi to take action

The full power of your language is available, including loops, conditionals, classes, functions, and packages.

Programs express their desired state by creating resource objects in code. This communicates to Pulumi what cloud resources will be required by the program. Here is a simple example that uses an AWS S3 bucket:

var aws = require("@pulumi/aws");
const bucket = new aws.s3.Bucket("my-bucket");
import * as aws from "@pulumi/aws";
const bucket = new aws.s3.Bucket("my-bucket");
from pulumi_aws import s3
bucket = s3.Bucket('my-bucket')
package main

import (
    "github.com/pulumi/pulumi-aws/sdk/go/aws/s3"
    "github.com/pulumi/pulumi/sdk/go/pulumi"
)

func main() {
    pulumi.Run(func (ctx *pulumi.Context) error {
        _, err := s3.NewBucket(ctx, "my-bucket", nil)
        return err
    })
}

The Bucket object allocated above is called a resource, and it describes your program’s cloud requirements so that Pulumi can create and manage them. This is immutable infrastructure as code.


Next up, let’s create a project to house our program. From there, we can start deploying it!

2/8