On this page

Pulumi

Manage Statsig feature gates, experiments, and dynamic configs as code with Pulumi, including provider setup and resource definition examples.

The Statsig Pulumi Provider lets you configure your gates and experiments using Pulumi Infrastructure as Code. The provider synchronizes with Statsig through the Console API. If the Pulumi Provider doesn't support what you need, refer to the Console API.

Installation

The Statsig provider is available as a package in the following Pulumi languages:

Configuration

Configure your Pulumi.yaml file with your Console API key before using the provider:

yaml
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs # or python, go, dotnet
config:
  statsig:consoleApiKey:
    value: 'YOUR_CONSOLE_API_KEY'

Configuration reference

  • consoleApiKey (String) - The Statsig Console API key you retrieve from the Statsig Console.

Example usage

TypeScript

typescript
import * as pulumi from "@pulumi/pulumi";
import * as statsig from "@statsig/pulumi-statsig";

// Create a Feature Gate
const gate = new statsig.Gate("my-gate", {});

Python

python
import pulumi
import pulumi_statsig as statsig

# Create a Feature Gate
gate = statsig.Gate("my-gate")

Go

go
package main

import (
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    "github.com/statsig-io/pulumi-statsig/sdk/go/statsig"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        // Create a Feature Gate
        _, err := statsig.NewGate(ctx, "my-gate", nil)
        if err != nil {
            return err
        }
        return nil
    })
}

C#

csharp
using Pulumi;
using Statsig = Statsig.Pulumi;

return await Deployment.RunAsync(() => 
{
    // Create a Feature Gate
    var gate = new Statsig.Gate("my-gate");
});

Supported features

The provider supports the following Statsig configurations:

  • Gates
  • Experiments

Coming Soon:

  • Dynamic Configs
  • Segments
If you need more from the Pulumi Provider, ask in the Statsig Slack channel.

Was this helpful?