Pulumi Examples

repository·master·Indexed 25 days ago

https://github.com/pulumi/examples

A collection of Pulumi examples demonstrating how to build and deploy infrastructure across various cloud providers and programming languages. Includes guides for deploying Alicloud ECS instances with TypeScript, AWS API Gateway routes using Go, Python, and TypeScript, and AWS Ansible Wordpress deployments.

Tokens
397.3K
Snippets
847
Records
1.3K
Agent score
79%

What's inside pulumi-examples

  1. Host a Static Website on Amazon S3 using Python and Pulumi

    master

    This example demonstrates how to host a static website using Amazon S3's website hosting support. It provisions an S3 bucket, configures it for website hosting, uploads static assets (like index.html, python.png, and favicon.png), and applies a bucket policy to allow public access.

    For a detailed conceptual walkthrough, refer to the Static Website on AWS S3 tutorial.

  2. Deploy a containerized Ruby on Rails app on GCP with GKE and Cloud SQL

    master

    This Pulumi example demonstrates an end-to-end deployment of a containerized Ruby on Rails application on Google Cloud Platform (GCP). The deployment includes:

    • Google Kubernetes Engine (GKE): Provisioning a managed Kubernetes cluster.
    • Google Cloud SQL: Provisioning a managed PostgreSQL database.
    • Docker Hub: Building a container image from the application code and publishing it to Docker Hub.
    • Kubernetes Service: Deploying the container image as a service within the GKE cluster.

    The entire infrastructure and application deployment are managed through a single pulumi up command using TypeScript.

  3. Deploy a Web Server Component on Azure Virtual Machines

    master
    This example demonstrates how to provision a configurable number of Linux web servers in Azure using a reusable Pulumi component. The WebServer component class abstracts the complexity of virtual machine creation. Upon successful deployment, the example outputs the public IP addresses of the provisioned servers.
  4. Writing Policies for Testing Pulumi Programs with CrossGuard

    master
    This example demonstrates how to implement Policy as Code using Pulumi's CrossGuard framework. It includes both the infrastructure definition and the testing logic, all written in TypeScript. CrossGuard allows you to define rules that are evaluated during the Pulumi deployment process, ensuring your infrastructure adheres to security or compliance standards before resources are actually provisioned.
  5. Deploy the Azure Virtual Data Center (VDC) example

    master

    This Pulumi example deploys an Azure Virtual Data Center (VDC) using a hub-and-spoke network architecture. It includes:

    • Hub-and-spoke network stacks with ExpressRoute and VPN Gateways.
    • Azure Firewall guarding a DMZ (with provision for forced tunneling).
    • Azure Bastion.
    • Configurable subnets for shared services in the hub and application environments in the spokes.

    Architecture Details:

    • Centralized Firewall: Custom routing redirects traffic to/from hubs, spokes, and the DMZ through the Azure Firewall.
    • Scalability: The firewall scales as a service to handle throughput.
    • High Availability: Stacks can be deployed in Azure paired regions for Production/Disaster Recovery or High Availability.
    • Connectivity: Global VNet Peering connects hubs across separate stacks into a symmetric network.

    Technical Implementation Patterns:

    • Uses pulumi.ComponentResource to compose low-level resources into reusable high-level abstractions.
    • Uses pulumi.StackReference to relate multiple stacks.
    • Uses Python's ipaddress module for network address configuration and validation.
    https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/azure-py-virtual-data-center/README.md
  6. Deploy ECS Anywhere with AWS and DigitalOcean

    master

    This Pulumi example demonstrates how to deploy an Amazon Elastic Container Service (ECS) Anywhere cluster along with a dockerized application to DigitalOcean. The infrastructure includes:

    • An AWS ECS Cluster.
    • An AWS ECR Repository to host the application image.
    • DigitalOcean Droplets acting as nodes, positioned behind a DigitalOcean Load Balancer for zero-downtime updates.
    • AWS IAM Roles and policies for task execution and SSM connectivity.
    • AWS SSM Activation to allow DigitalOcean droplets to register with AWS Systems Manager.
  7. Deploy a serverless C# application using raw AWS resources

    master

    This example demonstrates how to deploy a complete serverless C# application using raw AWS resources from the pulumi_aws provider, specifically aws.apigateway.RestApi, aws.lambda_.Function, and aws.dynamodb.Table.

    It highlights two key capabilities:

    1. Direct Resource Programming: You can program raw AWS resources directly instead of using higher-level abstractions like pulumi_cloud.
    2. Cross-Language Management: You can manage existing application code (in this case, a C# application using .NET Core 3.1) within a Pulumi program written in a different language like Python.

    To use this example, you must build the C# application code before running pulumi up.

  8. Automate AWS Organizations member accounts with Pulumi

    master

    This TypeScript example demonstrates how to automate the creation of member accounts within AWS Organizations using Pulumi. It also includes the creation of sample backup and tag policies at the Organizational Unit (OU) level.

    Important Note on Account Lifecycle: This application creates AWS accounts. When an account is closed, it enters a suspended state for 90 days. You will not be able to delete the Organizational Unit (OU) containing a closed account until that 90-day period has elapsed.

  9. Deploy an OAuth Server for Netlify CMS on AWS

    master

    This project provides an infrastructure example to deploy a custom OAuth Client Server on AWS. This is required when hosting a Netlify CMS project on AWS S3 instead of Netlify, as you must provide your own OAuth provider to handle authentication for backends like GitHub, Bitbucket, or GitLab.

    Infrastructure Components:

    • AWS Certificate Manager (ACM): Creates and validates SSL certificates.
    • AWS ECS Fargate: Runs the OAuth provider as a Docker container.
    • AWS Route53: Manages the DNS and creates an Alias Record for the OAuth server domain.

    Backend Support: While the example uses GitHub, you can support Bitbucket or GitLab by updating the Authorization callback URL in your OAuth application registration to:

    • Bitbucket: https://{{the domain of your OAuth App}}/bitbucket/callback
    • GitLab: https://{{the domain of your OAuth App}}/gitlab/callback
  10. Zero Downtime Migration of EKS Node Groups

    master
    This Pulumi example demonstrates how to perform a zero-downtime migration of workloads between EKS node groups. It creates an Amazon EKS cluster with existing node groups and a running workload, then showcases the process of adding a new node group and migrating the workload to it without service interruption.
  11. Host a Static Website on Amazon S3 with the AWS Native Provider

    master

    This example demonstrates how to host a static website using Amazon S3's website support. It utilizes a combination of the Pulumi AWS Classic provider and the AWS Native provider (Cloud Control API) to manage resources.

    Key resources managed in this example include:

    • aws-native:s3:Bucket for the S3 bucket.
    • aws:s3:BucketPolicy for bucket permissions.
    • aws:s3:BucketObject for hosting files like index.html and favicon.png.

    For a detailed walkthrough, refer to the Static Website on AWS S3 tutorial.