Cloud Native Programming

Cloud Infrastructure Automation for AWS with Pulumi

Pulumi provides a cloud native programming model for AWS to create containers, serverless functions, and infrastructure, with all the benefits of immutable infrastructure, and real programming languages.

Find out how to program the cloud with Pulumi and AWS.

Need help with cloud infrastructure automation on AWS? Drop us a line.

Benefits of Pulumi

Real Code

Pulumi is infrastructure as real code. This means you get all the benefits of your favorite language and tool for provisioning cloud infrastructure: code completion, error checking, versioning, IDE support, and general productivity gains - without the need to manage YAML and DSL syntax.

Reusable Components

As Pulumi is code, you can build up a library of packages to further enhance efficiency. Build repeatable practices through versioned packages such as: standard policies, network best practices, architecture blueprints - and deploy them to your team.

Immutable Infrastructure

Pulumi provides the computation of necessary cloud resources with a 'Cloud Resource DAG' ensuring successful deployment of cloud infrastructure - efficiently building, updating, and destroying cloud resources as required.

Serverless

Creating a Serverless REST API

With Pulumi, you can combine infrastructure definitions and application code in one program. The @pulumi/cloud-aws library is a set of Pulumi components that provide a higher-level abstraction over AWS. So, instead of provisioning an API Gateway instance, Lambda functions, and setting up IAM roles, you can use this library and define application code at the same time as the infrastructure it depends on.

This example shows how to create a simple REST API that counts the number of times a route has been hit. To implement this API, we need a DynamoDB table, an API endpoint, and a Lambda function.

Find many other examples here.

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

const cloud = require("@pulumi/cloud-aws");

// Create a mapping from 'route' to a count
let counterTable = new cloud.Table("counterTable", "route");
        
// Create an API endpoint
let endpoint = new cloud.API("hello-world");
        
endpoint.get("/{route+}", (req, res) => {
    let route = req.params["route"];
    console.log(`Getting count for '${route}'`);
        
    // get previous value and increment
    // reference outer `counterTable` object
    counterTable.get({ route }).then(value => {
        let count = (value && value.count) || 0;
        counterTable.insert({ route, count: ++count }).then(() 
        => {
            res.status(200).json({ route, count });
            console.log(`Got count ${count} for '${route}'`);
        });
    });
});
        
exports.endpoint = endpoint.publish().url;
Containers

Build and deploy containers to AWS

Pulumi supports programming against container orchestrators – Amazon’s ECS, EKS, and AWS Fargate. Pulumi is entirely unopinionated about how containers are built, published, and deployed to your orchestrator.

This code runs Nginx with 2 load balanced replicas listening on port 80. By default, this will run in Fargate when targeting AWS, which means you can skip the complications of configuring an orchestrator. After running pulumi up, the auto-assigned URL will be printed.

Find many other examples here.

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

// Deploy a pre-built container image
// to AWS Fargate

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

let nginx = new cloud.Service("nginx", {
    image: "nginx",
    ports: [{ port: 80 }],
    replicas: 2,
});

export let url = nginx.defaultEndpoint;

// Deploy a custom container image based on nginx
// to AWS Fargate

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

let nginx = new cloud.Service("nginx", {
    build: ".",
    ports: [{ port: 80 }],
    replicas: 2,
});
            
export let url = nginx.defaultEndpoint;
    
Infrastructure

Creating a Simple Web Server

Pulumi gives you a way to express infrastructure configuration using your favorite programming language.

This code uses TypeScript on Node.js to define the necessary security group, and defines a very simple web server, and then creates the instance, before exporting the IP and Hostname.

Find many other examples here.

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

const aws = require("@pulumi/aws");
        
let size = "t2.micro";
let ami  = "ami-7172b611"
    
    // create a new security group for port 80
let group = new aws.ec2.SecurityGroup("web-secgrp", { 
    ingress: [
        { protocol: "tcp", fromPort: 22, 
            toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, 
            toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
});
    
// create a simple web server
let userData = 
    `#!/bin/bash
    echo "Hello, World!" > index.html
    nohup python -m SimpleHTTPServer 80 &`;
    
let server = new aws.ec2.Instance("web-server-www", {
    tags: { "Name": "web-server-www" },
    instanceType: size,
    securityGroups: [ group.name ], 
    ami: ami,
    userData: userData              
});
    
exports.publicIp = server.publicIp;
exports.publicHostName = server.publicDns;
        

How Pulumi Works

Featured Customer

Learning Machine

Learning Machine

Learning Machine, a blockchain SaaS company faced two challenges with their cloud infrastructure:

  1. Skills gaps between Dev and DevOps creating silos, and fragility.
  2. The need to more rapidly provision their expanding roster of new customers.

By moving to Pulumi, Learning Machine were able to solve both challenges with significant increases in capability:

25,000 Lines of CloudFormation reduced to 500 Lines of JavaScript
New customer provisioning time reduced from 3 weeks to 1 hour

Pulumi has given our team the tools and framework to achieve a unified development and DevOps model, boosting productivity and taking our business to any cloud environment that our customers need. We retired 25,000 lines of complex code that few team members understood and replaced it with 100s of lines in a real programming language.

Get started with Pulumi

Pulumi works with your favorite language, and can be used with any cloud.

Install Pulumi

Setup

Configure

Try our tutorials

Quickstarts

Tour

Read the docs

Reference

Examples

Let Pulumi assist with your cloud infrastructure

Need help with cloud infrastructure automation on AWS? Drop us a line.

More from Pulumi

Migrate to Pulumi

In this video, Pulumi CTO, Luke Hoban, discusses how to begin to migrate to Pulumi from existing tools such as CloudFormation and Terraform.

Learn more

Serverless, Containers, and Infrastructure

In this blog post, we show productive Pulumi can be at combining different aspects of cloud architecture for truly cloud native programming.

Learn more