Pulumi Provider
Use FeatureSignals with Pulumi to manage feature flags, segments, environments, API keys, and webhooks in TypeScript, Python, Go, or C#. Full type safety, IDE autocompletion, and integration with your existing Pulumi stacks.
Installation
TypeScript / JavaScript
TypeScript installBash
1
npm install @featuresignals/pulumi
Python
Python installBash
1
pip install pulumi-featuresignals
Go
Go installBash
1
go get github.com/featuresignals/pulumi-featuresignals/sdk
Provider Configuration
Configure the provider with your API token. Use Pulumi config secrets to keep tokens out of source control:
Set API tokenBash
1
2
# Set the API token as a Pulumi secret
pulumi config set featuresignals:apiToken --secret
TypeScript Example
Create a project with environments, a segment, and a feature flag using TypeScript:
index.tsTypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as pulumi from "@pulumi/pulumi";
import * as featuresignals from "@featuresignals/pulumi";
// Create a project
const webapp = new featuresignals.Project("webapp", {
key: "webapp",
name: "Web Application",
description: "Main customer-facing web application",
});
// Create environments
const staging = new featuresignals.Environment("staging", {
projectKey: webapp.key,
key: "staging",
name: "Staging",
});
const production = new featuresignals.Environment("production", {
projectKey: webapp.key,
key: "production",
name: "Production",
});
// Define a reusable segment
const betaUsers = new featuresignals.Segment("beta-users", {
projectKey: webapp.key,
key: "beta-users",
name: "Beta Users",
rules: [
{
attribute: "email",
operator: "ends_with",
values: ["@beta.featuresignals.com"],
},
],
});
// Create a feature flag
const checkoutV2 = new featuresignals.Flag("checkout-v2", {
projectKey: webapp.key,
key: "checkout-v2",
name: "Checkout v2",
type: "boolean",
defaultValue: false,
targeting: {
rules: [
{
segmentKey: betaUsers.key,
serveValue: true,
},
],
},
rollout: {
percentage: 10,
serveValue: true,
},
});
// Create an API key for the production environment
const prodKey = new featuresignals.ApiKey("prod-sdk", {
projectKey: webapp.key,
name: "Production SDK Key",
type: "server",
environmentKeys: [production.key],
});
// Export the API key secret (sensitive)
export const apiKeySecret = prodKey.token;
Python Example
The same configuration in Python:
__main__.pyPython
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import pulumi
import pulumi_featuresignals as featuresignals
# Create a project
webapp = featuresignals.Project("webapp",
key="webapp",
name="Web Application",
description="Main customer-facing web application",
)
# Create environments
staging = featuresignals.Environment("staging",
project_key=webapp.key,
key="staging",
name="Staging",
)
production = featuresignals.Environment("production",
project_key=webapp.key,
key="production",
name="Production",
)
# Define a reusable segment
beta_users = featuresignals.Segment("beta-users",
project_key=webapp.key,
key="beta-users",
name="Beta Users",
rules=[{
"attribute": "email",
"operator": "ends_with",
"values": ["@beta.featuresignals.com"],
}],
)
# Create a feature flag
checkout_v2 = featuresignals.Flag("checkout-v2",
project_key=webapp.key,
key="checkout-v2",
name="Checkout v2",
type="boolean",
default_value=False,
targeting={
"rules": [{
"segment_key": beta_users.key,
"serve_value": True,
}],
},
rollout={
"percentage": 10,
"serve_value": True,
},
)
# Create an API key
prod_key = featuresignals.ApiKey("prod-sdk",
project_key=webapp.key,
name="Production SDK Key",
type="server",
environment_keys=[production.key],
)
pulumi.export("api_key_secret", prod_key.token)
CI/CD Integration
Pulumi integrates naturally with CI/CD pipelines. Here's a GitHub Actions workflow that previews flag changes on PR and applies on merge:
.github/workflows/feature-flags.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Feature Flag Management
on:
pull_request:
paths: ["flags/**"]
push:
branches: [main]
paths: ["flags/**"]
jobs:
flags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
working-directory: flags
- name: Pulumi Preview
if: github.event_name == 'pull_request'
uses: pulumi/actions@v5
with:
command: preview
stack-name: production
work-dir: flags
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- name: Pulumi Up
if: github.event_name == 'push'
uses: pulumi/actions@v5
with:
command: up
stack-name: production
work-dir: flags
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}