2016-10-19 16:25:12 +02:00
|
|
|
---
|
|
|
|
layout: "gitlab"
|
|
|
|
page_title: "Provider: GitLab"
|
|
|
|
sidebar_current: "docs-gitlab-index"
|
|
|
|
description: |-
|
|
|
|
The GitLab provider is used to interact with GitLab organization resources.
|
|
|
|
---
|
|
|
|
|
|
|
|
# GitLab Provider
|
|
|
|
|
|
|
|
The GitLab provider is used to interact with GitLab organization resources.
|
|
|
|
|
|
|
|
The provider allows you to manage your GitLab organization's members and teams easily.
|
|
|
|
It needs to be configured with the proper credentials before it can be used.
|
|
|
|
|
|
|
|
Use the navigation to the left to read about the available resources.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
2017-04-26 19:44:05 +02:00
|
|
|
```hcl
|
2016-10-19 16:25:12 +02:00
|
|
|
# Configure the GitLab Provider
|
|
|
|
provider "gitlab" {
|
2017-05-28 22:46:44 +02:00
|
|
|
token = "${var.gitlab_token}"
|
2016-10-19 16:25:12 +02:00
|
|
|
}
|
|
|
|
|
2017-05-29 16:04:51 +02:00
|
|
|
# Add a project owned by the user
|
2016-10-19 16:25:12 +02:00
|
|
|
resource "gitlab_project" "sample_project" {
|
2017-05-29 16:04:51 +02:00
|
|
|
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 deploy key to the project
|
|
|
|
resource "gitlab_deploy_key" "sample_deploy_key" {
|
|
|
|
project = "${gitlab_project.sample_project.id}"
|
|
|
|
title = "terraform example"
|
|
|
|
key = "ssh-rsa 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}"
|
2016-10-19 16:25:12 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported in the `provider` block:
|
|
|
|
|
|
|
|
* `token` - (Optional) This is the GitLab personal access token. It must be provided, but
|
|
|
|
it can also be sourced from the `GITLAB_TOKEN` environment variable.
|
|
|
|
|
|
|
|
* `base_url` - (Optional) This is the target GitLab base API endpoint. Providing a value is a
|
2017-05-25 08:51:42 +02:00
|
|
|
requirement when working with GitLab CE or GitLab Enterprise e.g. https://my.gitlab.server/api/v3/.
|
|
|
|
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.
|