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.
Authorizations
Section titled “ Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “ Path Parameters ”Request Body required
Section titled “ Request Body required ” Media type application/json
object
state_name
required
Terraform state name to protect. Maximum 255 characters. Must be unique per project.
string
minimum_access_level_for_write
required
Minimum GitLab access level required to write to the Terraform state. Valid values: developer, maintainer, owner, admin.
string
allowed_from
Source restriction for write requests. Default: anywhere. Valid values: anywhere, ci_only, ci_on_protected_branch_only.
string
Responses
Section titled “ Responses ”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