gitlab_branch (Resource)

The gitlab_branch resource allows to manage the lifecycle of a repository branch.

Upstream API: GitLab REST API docs

Example Usage

# Create a project for the branch to use
resource "gitlab_project" "example" {
  name         = "example"
  description  = "An example project"
  namespace_id = gitlab_group.example.id
}

resource "gitlab_branch" "example" {
  name    = "example"
  ref     = "main"
  project = gitlab_project.example.id
}

Schema

Required

Read-Only

Nested Schema for commit

Read-Only:

Import

Import is supported using the following syntax:

# Gitlab branches can be imported with a key composed of `<project_id>:<branch_name>`, e.g.
terraform import gitlab_branch.example "12345:develop"