# Managing Gates With Terraform

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

You can create a .tf file (Terraform File) to configure your Statsig feature gates. The file supports all features of [console/v1/gates](https://docs.statsig.com/console-api/introduction). 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:

```go
terraform {
  required_providers {
    statsig = {
      version = "x.x.x"
      source  = "statsig-io/statsig"
    }
  }
}
```

## Basic example

The following creates a basic gate resource:

```go
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](https://docs.statsig.com/console-api/introduction#all-conditions) 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. |

```go
conditions {
  type         = "custom_field"
  target_value = ["31"]
  operator     = "gt"
  field        = "age"
}
```

Refer to the full list of [conditions](https://docs.statsig.com/console-api/introduction#all-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
