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.
# 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
}
base_url
(String) This is the target GitLab base API endpoint. Providing a value is a requirement when working with GitLab CE or GitLab Enterprise e.g. https://my.gitlab.server/api/v4/
. It is optional to provide this value and it can also be sourced from the GITLAB_BASE_URL
environment variable. The value must end with a slash.cacert_file
(String) This is a file containing the ca cert to verify the gitlab instance. This is available for use when working with GitLab CE or Gitlab Enterprise with a locally-issued or self-signed certificate chain.client_cert
(String) File path to client certificate when GitLab instance is behind company proxy. File must contain PEM encoded data.client_key
(String) File path to client key when GitLab instance is behind company proxy. File must contain PEM encoded data. Required when client_cert
is set.early_auth_check
(Boolean) (Experimental) By default the provider does a dummy request to get the current user in order to verify that the provider configuration is correct and the GitLab API is reachable. Set this to false
to skip this check. This may be useful if the GitLab instance does not yet exist and is created within the same terraform module. It may be sourced from the GITLAB_EARLY_AUTH_CHECK
. This is an experimental feature and may change in the future. Please make sure to always keep backups of your state.insecure
(Boolean) When set to true this disables SSL verification of the connection to the GitLab instance.token
(String, Sensitive) The OAuth2 Token, Project, Group, Personal Access Token or CI Job Token used to connect to GitLab. The OAuth method is used in this provider for authentication (using Bearer authorization token). See https://docs.gitlab.com/ee/api/#authentication for details. It may be sourced from the GITLAB_TOKEN
environment variable.