Convert Figma logo to code with AI

pulumi logopulumi

Pulumi - Infrastructure as Code in any programming language 🚀

23,349
1,208
23,349
2,317

Top Related Projects

45,477

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

12,260

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.

3,395

Bicep is a declarative language for describing and deploying Azure resources

65,475

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.

The Cloud Foundation toolkit provides GCP best practices as code.

Quick Overview

Pulumi is an open-source infrastructure as code (IaC) tool that allows developers to define and manage cloud resources using familiar programming languages. It supports multiple cloud providers and enables teams to create, deploy, and manage infrastructure using languages like TypeScript, Python, Go, and C#.

Pros

  • Supports multiple programming languages, allowing developers to use their preferred language
  • Provides a unified workflow across various cloud providers (AWS, Azure, Google Cloud, etc.)
  • Offers strong typing and IDE support, enhancing developer productivity
  • Enables easy sharing and reuse of infrastructure code through packages

Cons

  • Steeper learning curve compared to declarative IaC tools like Terraform
  • Requires knowledge of a supported programming language
  • May introduce more complexity for simple infrastructure setups
  • Limited community resources compared to more established tools like Terraform

Code Examples

  1. Creating an AWS S3 bucket:
import * as aws from "@pulumi/aws";

const bucket = new aws.s3.Bucket("my-bucket", {
    website: {
        indexDocument: "index.html",
    },
});

export const bucketName = bucket.id;
  1. Deploying an Azure Function App:
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";

const resourceGroup = new azure.resources.ResourceGroup("myResourceGroup");

const storageAccount = new azure.storage.StorageAccount("sa", {
    resourceGroupName: resourceGroup.name,
    sku: {
        name: azure.storage.SkuName.Standard_LRS,
    },
    kind: azure.storage.Kind.StorageV2,
});

const appServicePlan = new azure.web.AppServicePlan("asp", {
    resourceGroupName: resourceGroup.name,
    sku: {
        name: "Y1",
        tier: "Dynamic",
    },
});

const functionApp = new azure.web.WebApp("fa", {
    resourceGroupName: resourceGroup.name,
    serverFarmId: appServicePlan.id,
    kind: "functionapp",
    siteConfig: {
        appSettings: [
            { name: "FUNCTIONS_WORKER_RUNTIME", value: "node" },
            { name: "WEBSITE_NODE_DEFAULT_VERSION", value: "~14" },
        ],
    },
});

export const functionAppName = functionApp.name;
  1. Creating a Google Cloud Storage bucket:
import * as gcp from "@pulumi/gcp";

const bucket = new gcp.storage.Bucket("my-bucket", {
    location: "US",
    forceDestroy: true,
});

export const bucketName = bucket.name;

Getting Started

  1. Install Pulumi CLI: curl -fsSL https://get.pulumi.com | sh
  2. Set up your cloud provider credentials (e.g., AWS, Azure, GCP)
  3. Create a new Pulumi project:
    mkdir my-pulumi-project && cd my-pulumi-project
    pulumi new aws-typescript
    
  4. Define your infrastructure in the index.ts file
  5. Deploy your infrastructure:
    pulumi up
    

Competitor Comparisons

45,477

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.

Pros of Terraform

  • Mature ecosystem with extensive provider support
  • HCL (HashiCorp Configuration Language) is purpose-built for infrastructure
  • Large community and widespread adoption

Cons of Terraform

  • Limited programming constructs and abstraction capabilities
  • State management can be complex, especially in team environments
  • Steeper learning curve for those without infrastructure background

Code Comparison

Terraform (HCL):

resource "aws_instance" "example" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"
}

Pulumi (Python):

import pulumi_aws as aws

instance = aws.ec2.Instance("example",
    ami="ami-0c55b159cbfafe1f0",
    instance_type="t2.micro")

Pulumi offers a more familiar programming experience using general-purpose languages, while Terraform uses its domain-specific HCL. Pulumi provides better code reuse and abstraction capabilities, making it easier to create complex infrastructure patterns. However, Terraform's mature ecosystem and widespread adoption give it an edge in terms of community support and available resources.

Both tools are powerful for infrastructure as code, with Terraform being more established and Pulumi offering more flexibility and programming language options. The choice between them often depends on team expertise, project requirements, and existing infrastructure setup.

12,260

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code

Pros of AWS CDK

  • Native AWS integration with deep support for AWS services
  • Extensive AWS-specific constructs and best practices built-in
  • Seamless integration with AWS CloudFormation for deployment

Cons of AWS CDK

  • Limited to AWS ecosystem, not suitable for multi-cloud deployments
  • Steeper learning curve for developers unfamiliar with AWS services
  • Less flexibility in language choice compared to Pulumi

Code Comparison

AWS CDK (TypeScript):

import * as cdk from '@aws-cdk/core';
import * as s3 from '@aws-cdk/aws-s3';

const bucket = new s3.Bucket(this, 'MyBucket', {
  versioned: true,
});

Pulumi (TypeScript):

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

const bucket = new aws.s3.Bucket("my-bucket", {
  versioned: true,
});

Both AWS CDK and Pulumi allow infrastructure-as-code using familiar programming languages. AWS CDK is tightly integrated with AWS services and provides AWS-specific constructs, while Pulumi offers a more cloud-agnostic approach with support for multiple cloud providers. AWS CDK leverages CloudFormation for deployments, whereas Pulumi has its own state management and deployment system. The choice between the two depends on specific project requirements, cloud strategy, and developer preferences.

⚡ Serverless Framework – Effortlessly build apps that auto-scale, incur zero costs when idle, and require minimal maintenance using AWS Lambda and other managed cloud services.

Pros of Serverless

  • Focused specifically on serverless architectures, providing a streamlined experience for serverless development
  • Extensive plugin ecosystem for integrating with various cloud providers and tools
  • Strong community support and a large number of examples and templates

Cons of Serverless

  • Limited to serverless architectures, less flexible for other infrastructure needs
  • Configuration can become complex for large projects with many functions
  • Steeper learning curve for developers new to serverless concepts

Code Comparison

Serverless (YAML configuration):

service: my-service
provider:
  name: aws
  runtime: nodejs14.x
functions:
  hello:
    handler: handler.hello

Pulumi (TypeScript):

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

const lambdaFunction = new aws.lambda.Function("myFunction", {
    code: new pulumi.asset.AssetArchive({
        "index.js": new pulumi.asset.StringAsset("exports.handler = async (event) => { ... }"),
    }),
    handler: "index.handler",
    runtime: "nodejs14.x",
});

Both Pulumi and Serverless are popular infrastructure-as-code tools, but they have different focuses. Serverless is specialized for serverless architectures, while Pulumi offers a more general-purpose approach to infrastructure management using familiar programming languages.

3,395

Bicep is a declarative language for describing and deploying Azure resources

Pros of Bicep

  • Native Azure integration with seamless Azure CLI and Azure PowerShell support
  • Simpler syntax compared to ARM templates, making it easier to learn and use
  • Faster deployment times due to its compilation to ARM templates

Cons of Bicep

  • Limited to Azure resources only, lacking multi-cloud support
  • Less flexibility in terms of programming constructs and custom logic
  • Smaller ecosystem and community compared to Pulumi

Code Comparison

Bicep:

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
  name: 'mystorageaccount'
  location: 'eastus'
  sku: {
    name: 'Standard_LRS'
  }
}

Pulumi (TypeScript):

import * as azure from "@pulumi/azure-native";

const storageAccount = new azure.storage.StorageAccount("mystorageaccount", {
    resourceGroupName: resourceGroup.name,
    sku: {
        name: azure.storage.SkuName.Standard_LRS,
    },
});

Both examples create a storage account in Azure, but Pulumi offers more programming language options and can be used for multi-cloud deployments. Bicep's syntax is more concise and specifically tailored for Azure resources, while Pulumi provides a more flexible, general-purpose infrastructure-as-code solution.

65,475

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.

Pros of Ansible

  • Agentless architecture, requiring only SSH access to managed nodes
  • Extensive module library for various tasks and integrations
  • YAML-based playbooks are easy to read and write

Cons of Ansible

  • Limited support for stateful infrastructure management
  • Primarily designed for configuration management, less suited for complex infrastructure provisioning
  • Lack of native support for rollbacks and drift detection

Code Comparison

Ansible playbook example:

- name: Create EC2 instance
  ec2:
    key_name: mykey
    instance_type: t2.micro
    image: ami-123456
    wait: yes
    group: webserver
    count: 1
    vpc_subnet_id: subnet-29e63245
    assign_public_ip: yes

Pulumi code example (Python):

ec2_instance = aws.ec2.Instance("my-instance",
    instance_type="t2.micro",
    ami="ami-123456",
    tags={
        "Name": "webserver",
    },
    vpc_security_group_ids=[group.id],
    subnet_id="subnet-29e63245")

Both examples create an EC2 instance, but Pulumi uses a programming language (Python in this case) for infrastructure definition, while Ansible uses YAML for playbook creation. Pulumi's approach allows for more complex logic and better integration with existing development workflows.

The Cloud Foundation toolkit provides GCP best practices as code.

Pros of cloud-foundation-toolkit

  • Specifically designed for Google Cloud Platform, offering deep integration and best practices
  • Provides pre-built, production-ready templates for common GCP architectures
  • Includes robust testing frameworks and CI/CD pipelines tailored for GCP deployments

Cons of cloud-foundation-toolkit

  • Limited to Google Cloud Platform, lacking multi-cloud support
  • Steeper learning curve for users not familiar with GCP-specific concepts
  • Less flexibility in terms of programming language choice compared to Pulumi

Code Comparison

cloud-foundation-toolkit (Terraform):

resource "google_compute_instance" "default" {
  name         = "test"
  machine_type = "n1-standard-1"
  zone         = "us-central1-a"
}

Pulumi (Python):

instance = gcp.compute.Instance("test",
    machine_type="n1-standard-1",
    zone="us-central1-a"
)

Both examples create a Google Compute Engine instance, but Pulumi allows for using general-purpose programming languages, while cloud-foundation-toolkit relies on Terraform's HCL syntax.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Slack GitHub Discussions NPM version Python version NuGet version GoDoc License

Infrastructure as Code in any Programming Language

Pulumi Infrastructure as Code is the easiest way to build and deploy infrastructure, of any architecture and on any cloud, using programming languages that you already know and love. Code and ship infrastructure faster with your favorite languages and tools, and embed IaC anywhere with Automation API.

Simply write code in your favorite language and Pulumi automatically provisions and manages your resources on AWS, Azure, Google Cloud Platform, Kubernetes, and 120+ providers using an infrastructure-as-code approach. Skip the YAML, and use standard language features like loops, functions, classes, and package management that you already know and love.

For example, create three web servers:

const aws = require("@pulumi/aws");
const sg = new aws.ec2.SecurityGroup("web-sg", {
    ingress: [{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] }],
});
for (let i = 0; i < 3; i++) {
    new aws.ec2.Instance(`web-${i}`, {
        ami: "ami-7172b611",
        instanceType: "t2.micro",
        vpcSecurityGroupIds: [sg.id],
        userData: `#!/bin/bash
            echo "Hello, World!" > index.html
            nohup python -m SimpleHTTPServer 80 &`,
    });
}

Or a simple serverless timer that archives Hacker News every day at 8:30AM:

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

const snapshots = new aws.dynamodb.Table("snapshots", {
    attributes: [{ name: "id", type: "S", }],
    hashKey: "id", billingMode: "PAY_PER_REQUEST",
});

aws.cloudwatch.onSchedule("daily-yc-snapshot", "cron(30 8 * * ? *)", () => {
    require("https").get("https://news.ycombinator.com", res => {
        let content = "";
        res.setEncoding("utf8");
        res.on("data", chunk => content += chunk);
        res.on("end", () => new aws.sdk.DynamoDB.DocumentClient().put({
            TableName: snapshots.name.get(),
            Item: { date: Date.now(), content },
        }).promise());
    }).end();
});

Many examples are available spanning containers, serverless, and infrastructure in pulumi/examples.

Pulumi is open source under the Apache 2.0 license, supports many languages and clouds, and is easy to extend. This repo contains the pulumi CLI, language SDKs, and core Pulumi engine, and individual libraries are in their own repos.

Welcome

  • Get Started with Pulumi: Deploy a simple application in AWS, Azure, Google Cloud, or Kubernetes using Pulumi.

  • Learn: Follow Pulumi learning pathways to learn best practices and architectural patterns through authentic examples.

  • Examples: Browse several examples across many languages, clouds, and scenarios including containers, serverless, and infrastructure.

  • Docs: Learn about Pulumi concepts, follow user-guides, and consult the reference documentation.

  • Registry: Find the Pulumi Package with the resources you need. Install the package directly into your project, browse the API documentation, and start building.

  • Secrets Management: Tame secrets sprawl and configuration complexity securely across all your cloud infrastructure and applications with Pulumi ESC.

  • Pulumi Roadmap: Review the planned work for the upcoming quarter and a selected backlog of issues that are on our mind but not yet scheduled.

  • Community Slack: Join us in Pulumi Community Slack. All conversations and questions are welcome.

  • GitHub Discussions: Ask questions or share what you're building with Pulumi.

Getting Started

Watch the video

See the Get Started guide to quickly get started with Pulumi on your platform and cloud of choice.

Otherwise, the following steps demonstrate how to deploy your first Pulumi program, using AWS Serverless Lambdas, in minutes:

  1. Install:

    To install the latest Pulumi release, run the following (see full installation instructions for additional installation options):

    $ curl -fsSL https://get.pulumi.com/ | sh
    
  2. Create a Project:

    After installing, you can get started with the pulumi new command:

    $ mkdir pulumi-demo && cd pulumi-demo
    $ pulumi new hello-aws-javascript
    

    The new command offers templates for all languages and clouds. Run it without an argument and it'll prompt you with available projects. This command created an AWS Serverless Lambda project written in JavaScript.

  3. Deploy to the Cloud:

    Run pulumi up to get your code to the cloud:

    $ pulumi up
    

    This makes all cloud resources needed to run your code. Simply make edits to your project, and subsequent pulumi ups will compute the minimal diff to deploy your changes.

  4. Use Your Program:

    Now that your code is deployed, you can interact with it. In the above example, we can curl the endpoint:

    $ curl $(pulumi stack output url)
    
  5. Access the Logs:

    If you're using containers or functions, Pulumi's unified logging command will show all of your logs:

    $ pulumi logs -f
    
  6. Destroy your Resources:

    After you're done, you can remove all resources created by your program:

    $ pulumi destroy -y
    

To learn more, head over to pulumi.com for much more information, including tutorials, examples, and details of the core Pulumi CLI and programming model concepts.

Platform

Languages

LanguageStatusRuntimeVersions
JavaScriptStableNode.jsCurrent, Active and Maintenance LTS versions
TypeScriptStableNode.jsCurrent, Active and Maintenance LTS versions
PythonStablePythonSupported versions
GoStableGoSupported versions
.NET (C#/F#/VB.NET)Stable.NETSupported versions
JavaStableJDK11+
YAMLStablen/an/a

EOL Releases

The Pulumi CLI v1 and v2 are no longer supported. If you are not yet running v3, please consider migrating to v3 to continue getting the latest and greatest Pulumi has to offer! :muscle:

Clouds

Visit the Registry for the full list of supported cloud and infrastructure providers.

Contributing

Visit CONTRIBUTING.md for information on building Pulumi from source or contributing improvements.

NPM DownloadsLast 30 Days