Use the GitLab provider to interact with GitLab resources, like users, groups, projects and more. You must configure the provider with the proper credentials before you can use it.

The provider uses the xanzy/go-gitlab library to interact with the GitLab REST API.

Each data source and resource references the appropriate upstream GitLab REST API documentation, which may be consumed to better understand the behavior of the API.

Use the navigation to the left to read about the valid data sources and resources.

This provider requires at least Terraform 1.0. A minimum of Terraform 1.4.0 is recommended.

Example Usage

# Configure the GitLab Provider
provider "gitlab" {
  token = var.gitlab_token
}

# Add a project owned by the user
resource "gitlab_project" "sample_project" {
  name = "example"
}

# Add a hook to the project
resource "gitlab_project_hook" "sample_project_hook" {
  project = gitlab_project.sample_project.id
  url     = "https://example.com/project_hook"
}

# Add a variable to the project
resource "gitlab_project_variable" "sample_project_variable" {
  project = gitlab_project.sample_project.id
  key     = "project_variable_key"
  value   = "project_variable_value"
}

# Add a deploy key to the project
resource "gitlab_deploy_key" "sample_deploy_key" {
  project = gitlab_project.sample_project.id
  title   = "terraform example"
  key     = "ssh-ed25519 AAAA..."
}

# Add a group
resource "gitlab_group" "sample_group" {
  name        = "example"
  path        = "example"
  description = "An example group"
}

# Add a project to the group - example/example
resource "gitlab_project" "sample_group_project" {
  name         = "example"
  namespace_id = gitlab_group.sample_group.id
}

Schema

Optional