1. Packages
  2. Standard Library
StandardLibrary v2.3.2 published on Tuesday, Feb 10, 2026 by Pulumi

Standard Library

std logo
StandardLibrary v2.3.2 published on Tuesday, Feb 10, 2026 by Pulumi
    Meet Neo: Your AI Platform Teammate

    The Pulumi Standard Library provider contains a set of string manipulation, mathematical, and utility functions that are identical across languages. These functions are especially useful for Pulumi YAML, which lacks native support for arbitrary string manipulation and mathematical operations.

    The expected use case is in Pulumi YAML programs, or Pulumi programs generated by Pulumi Eject.

    Examples

    Replace within a string

    import * as std from "@pulumi/std";
    
    // Simple string replacement
    const simpleReplace = std.str.replace({
        string: "fizz-bar",
        old: "bar",
        new: "buzz",
    });
    
    // Regular expression replacement
    const regexpReplace = std.str.regexp.replace({
        string: "fizz-foo-bar",
        old: "-.*",
        new: "-buzz",
    });
    
    export const simple = simpleReplace.result; // fizz-buzz
    export const regexp = regexpReplace.result; // fizz-buzz
    
    import pulumi_std as std
    
    # Simple string replacement
    simple_replace = std.str.replace(
        string="fizz-bar",
        old="bar",
        new="buzz"
    )
    
    # Regular expression replacement
    regexp_replace = std.str.regexp.replace(
        string="fizz-foo-bar",
        old="-.*",
        new="-buzz"
    )
    
    pulumi.export("simple", simple_replace.result)  # fizz-buzz
    pulumi.export("regexp", regexp_replace.result)  # fizz-buzz
    
    package main
    
    import (
        "github.com/pulumi/pulumi-std/sdk/v2/go/std"
        "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
        pulumi.Run(func(ctx *pulumi.Context) error {
            // Simple string replacement
            simpleReplace, err := std.Str.Replace(ctx, &std.StrReplaceArgs{
                String: pulumi.String("fizz-bar"),
                Old:    pulumi.String("bar"),
                New:    pulumi.String("buzz"),
            })
            if err != nil {
                return err
            }
    
            // Regular expression replacement
            regexpReplace, err := std.Str.Regexp.Replace(ctx, &std.StrRegexpReplaceArgs{
                String: pulumi.String("fizz-foo-bar"),
                Old:    pulumi.String("-.*"),
                New:    pulumi.String("-buzz"),
            })
            if err != nil {
                return err
            }
    
            ctx.Export("simple", simpleReplace.Result) // fizz-buzz
            ctx.Export("regexp", regexpReplace.Result) // fizz-buzz
            return nil
        })
    }
    
    using Pulumi;
    using Pulumi.Std;
    
    class MyStack : Stack
    {
        public MyStack()
        {
            // Simple string replacement
            var simpleReplace = Str.Replace(new StrReplaceArgs
            {
                String = "fizz-bar",
                Old = "bar",
                New = "buzz"
            });
    
            // Regular expression replacement
            var regexpReplace = Str.Regexp.Replace(new StrRegexpReplaceArgs
            {
                String = "fizz-foo-bar",
                Old = "-.*",
                New = "-buzz"
            });
    
            this.Simple = simpleReplace.Result; // fizz-buzz
            this.Regexp = regexpReplace.Result; // fizz-buzz
        }
    
        [Output] public Output<string> Simple { get; set; }
        [Output] public Output<string> Regexp { get; set; }
    }
    
    variables:
      simple-replace:
        Fn::str:replace:
          string: fizz-bar
          old: bar
          new: buzz
    
      regexp-replace:
        Fn::str:regexp:replace:
          string: fizz-foo-bar
          old: -.*
          new: -buzz
    
    outputs:
      simple-replace: # fizz-buzz
        ${simple-replace.result}
      regexp-replace: # fizz-buzz
        ${regexp-replace.result}
    
    std logo
    StandardLibrary v2.3.2 published on Tuesday, Feb 10, 2026 by Pulumi
      Meet Neo: Your AI Platform Teammate