Pulumi Tutorials

website·Indexed 41 days ago

https://www.pulumi.com/docs

A collection of guides and tutorials for provisioning and managing infrastructure as code across AWS, Azure, Google Cloud, and Kubernetes. Topics include deploying containerized applications to AKS, EKS, and ECS, managing secrets with Pulumi ESC, importing existing cloud infrastructure, and using Helm charts.

Tokens
252.5K
Snippets
1.6K
Records
1.8K
Agent score
70%

What's inside Pulumi

  1. Overview of Pulumi Drift Detection and Remediation

    Drift detection is a Pulumi Cloud feature that automates the identification and correction of discrepancies between the actual state of cloud resources and the desired state defined in Pulumi. Drift occurs when changes are made outside of Pulumi, such as manual updates via a cloud provider's console or CLI.

    Key capabilities include:

    • Detection Methods: Drift detection can be triggered via the Pulumi CLI, on-demand using 'click-to-deploy' actions in Pulumi Cloud, or via scheduled intervals.
    • Reporting: Discrepancies are logged in the Drift tab of the Pulumi Cloud console, providing a history of runs and specific resource details.
    • Notifications: Alerts can be sent via webhooks, Slack, Microsoft Teams, or email.
    • Remediation: Auto-remediation can be configured to refresh the last known desired state and correct drift without manual intervention.
    • CI/CD Integration: Drift detection can be integrated into custom pipelines using the pulumi refresh command.
  2. Overview of Pulumi Deployments

    Pulumi Deployments is a fully managed service for automating cloud infrastructure. It provides tools to power public/private cloud platforms, APIs, and self-service portals. Deployments can be triggered via three primary methods: the REST API, GitHub push-to-deploy (via the Pulumi GitHub App), or directly from the Pulumi Cloud console.
  3. Overview of Pulumi AWS Lambda support

    Pulumi provides extensions for the AWS provider in JavaScript and TypeScript that simplify the creation of serverless applications. It handles packaging, versioning, and configuration of Lambda resources, allowing developers to express functions using real code. Pulumi supports strong typing for event handler inputs and outputs across various AWS event sources.
  4. Use Pulumi secrets providers to encrypt statefile secrets

    Pulumi supports secrets providers that allow you to encrypt secrets stored in the Pulumi statefile. Instead of using the default Pulumi service encryption, you can use cloud-native or third-party providers such as AWS KMS, Azure Key Vault, Google Cloud KMS, or HashiCorp Vault.
  5. Deploy a serverless AWS application using TypeScript and Pulumi

    This example demonstrates how to build a serverless application by directly programming raw AWS resources using the @pulumi/aws package. The architecture consists of an API Gateway (aws.apigateway.RestAPI), a Lambda function (aws.lambda.Function), and a DynamoDB table (aws.dynamodb.Table). Notably, it shows that a Pulumi project written in TypeScript can manage application code written in another language (in this case, a C# .NET Core 3.1 application).
    # Clone the specific example directory
    git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
    git -C pulumi-examples sparse-checkout set aws-ts-serverless-raw
    cd pulumi-examples/aws-ts-serverless-raw
    
    # Initialize stack and install dependencies
    pulumi stack init dev
    npm install
    
    # Build the C# Lambda application
    dotnet publish app
    
    # Configure AWS region
    pulumi config set aws:region us-east-2
    
    # Deploy
    pulumi up
  6. Deploy a serverless S3 copy-and-zip application with Pulumi

    This example implements a serverless architecture where an AWS Lambda function triggers on new objects arriving in a source S3 bucket, zips the object, and copies it to a destination S3 bucket. It requires Pulumi, Node.js, and configured AWS credentials.
    # 1. Clone the specific example directory
    git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
    git -C pulumi-examples sparse-checkout set aws-ts-s3-lambda-copyzip
    cd pulumi-examples/aws-ts-s3-lambda-copyzip
    
    # 2. Initialize and configure the stack
    pulumi stack init dev
    pulumi config set aws:region us-east-1
    
    # 3. Install dependencies and deploy
    npm install
    pulumi up
  7. Verify Redis Enterprise Cloud connectivity via AWS EC2

    To test the architecture after running pulumi up:

    1. Locate the EC2 instance named pulumi-redis-cloud-tester in the AWS Console and connect via SSM Systems Manager.
    2. In the Redis Cloud console, find your database, select "Connect", and copy the Redis CLI connection string.
    3. Paste the connection string into the SSM shell to connect to the Redis instance and execute commands (e.g., INCR).
  8. Deploy a static website using Azure Blob Storage and CDN with Pulumi Go

    This example demonstrates how to configure static website hosting in Azure Storage and set up an Azure CDN to serve files from the Blob container origin. This architecture is particularly useful for serving files via HTTPS from custom domains.
    # 1. Clone the specific example directory
    git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
    git -C pulumi-examples sparse-checkout set azure-go-static-website
    cd pulumi-examples/azure-go-static-website
    
    # 2. Initialize Pulumi stack and configure Azure
    pulumi stack init dev
    az login
    pulumi config set azure-native:location westus
    
    # 3. Install Go dependencies and deploy
    go mod download
    pulumi up
    
    # 4. Retrieve the website endpoint
    pulumi stack output staticEndpoint
  9. Create AWS resources using AssumeRole in Pulumi Python

    The AWS provider in Pulumi supports AssumeRole functionality, allowing a program to create resources within the security context of a specific IAM Role. This is typically used when the IAM User executing the Pulumi program has permission to assume a more privileged role to perform specific infrastructure tasks.
  10. Deploy the AWS Slackbot mention notification example

    This example implements a Slackbot (@mentionbot) that posts notifications to a specific channel whenever a user is @mentioned. It uses a decoupled architecture: API Gateway receives the event, pushes it to an AWS SNS Topic to satisfy Slack's strict 200 OK response time requirements, and a Lambda function processes the message asynchronously.

    Prerequisites

    • Pulumi CLI installed
    • AWS credentials configured
    • Node.js installed
    # Clone the specific example directory
    git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
    git -C pulumi-examples sparse-checkout set aws-ts-slackbot
    cd pulumi-examples/aws-ts-slackbot
    
    # Initialize and deploy
    pulumi stack init mentionbot
    pulumi config set aws:region us-east-2
    npm install
    pulumi up
  11. Deploy a Kubernetes Guestbook application using Pulumi Python

    This example demonstrates how to build and deploy a multi-tier web application on Kubernetes and Docker. The application consists of three primary components: a single-instance Redis master for storage, multiple replicated Redis instances for read operations, and multiple web frontend instances.

    There are two implementation variants available:

    1. Simple: A direct port of the original Kubernetes YAML manifests.
    2. Components: An implementation using Pulumi component abstractions to reduce boilerplate and leverage a real programming language.
  12. Deploy Netlify CMS and OAuth on AWS using Pulumi

    This example demonstrates how to host Netlify CMS on AWS instead of Netlify, decoupling the CMS implementation from the target content repository. The architecture consists of two standalone Pulumi projects:

    1. CMS App: A React CMS app deployed as a static website on AWS S3, served via CloudFront and AWS Certificate Manager.
    2. OAuth Client: An external OAuth client deployed as an AWS Fargate service. This replaces Netlify's Identity Service to handle the retrieval of GitHub tokens.

    To integrate the two, the CMS configuration file (cms/public/config.yml) must be updated with the respective domains: site_domain for the CMS app and base_url for the OAuth client.

    # Clone only the specific example directory from the Pulumi examples repo
    git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
    git -C pulumi-examples sparse-checkout set aws-ts-netlify-cms-and-oauth
    cd pulumi-examples/aws-ts-netlify-cms-and-oauth