Skip to content

Create a Terraform state protection rule for a project

POST
/api/v4/projects/{id}/terraform/state_protection_rules

This feature was introduced in GitLab 19.1.

id
required
One of:
string

The ID or URL-encoded path of the project

Media type application/json
object
state_name
required

Terraform state name to protect. Maximum 255 characters. Must be unique per project.

string
nullable <= 255 characters
minimum_access_level_for_write
required

Minimum GitLab access level required to write to the Terraform state. Valid values: developer, maintainer, owner, admin.

string
>= 1 characters
Allowed values: developer maintainer owner admin
allowed_from

Source restriction for write requests. Default: anywhere. Valid values: anywhere, ci_only, ci_on_protected_branch_only.

string
nullable
Allowed values: anywhere ci_only ci_on_protected_branch_only

Created

Media type application/json
object
id
integer format: int64
project_id
integer format: int64
state_name
string
minimum_access_level_for_write
string
allowed_from
string
Example
{
"id": 1,
"project_id": 1,
"state_name": "production",
"minimum_access_level_for_write": "maintainer",
"allowed_from": "ci_only"
}

Bad Request

Unauthorized

Forbidden

Not Found

Unprocessable Entity