For AI agents: a documentation index is available at /llms.txt. Append .md to any page URL for markdown, or send Accept: text/markdown.
Managing Gates With Terraform
Define Statsig feature gates as Terraform resources, including rules, conditions, and rollout percentages, for fully reproducible feature flag setups.
You can create a .tf file (Terraform File) to configure your Statsig feature gates. The file supports all features of console/v1/gates. The layout is similar to the JSON body of a /gates request.
Require the Statsig provider and update the version to match your installed release:
terraform {
required_providers {
statsig = {
version = "x.x.x"
source = "statsig-io/statsig"
}
}
}
Basic example
The following creates a basic gate resource:
resource "statsig_gate" "my_gate" {
name = "my_gate"
description = "A short description of what this Gate is used for."
is_enabled = true
id_type = "userID"
rules {
name = "Public"
pass_percentage = 100
conditions {
type = "public"
}
}
}
Conditions
The provider supports all Console API conditions, but the syntax requires minor adjustments.
| Field | Type | Description |
|---|---|---|
| type | string | The type of condition. |
| operator | string | The form of evaluation to run against the target_value. |
| target_value | [string] | The value or values to evaluate. Must be an array, and elements must be strings. Wrap numbers in quotes, for example 31 becomes "31". |
| field | string | Only for the custom_field condition type. The name of the field to pull for evaluation from the "custom" object on a user. |
conditions {
type = "custom_field"
target_value = ["31"]
operator = "gt"
field = "age"
}
Refer to the full list of conditions.
You can find a full gate example in the open source Github repo https://github.com/statsig-io/terraform-provider-statsig/blob/main/examples/resources/statsig_gate/resource.tf
Was this helpful?