# dokploy_gitlab_provider (Resource)

A GitLab connection (Git > GitLab): the OAuth application that lets Dokploy list and clone repositories. Applications and composes then use the `gitlab` source block with this record's `id`.

~> **A person must authorize the application once in a browser.** Terraform stores the OAuth application credentials. Until someone opens Git > GitLab in the Dokploy UI and completes the authorization, Dokploy holds no access token, the `dokploy_gitlab_provider` data source reports `is_configured = false`, and a deploy from this provider fails.

~> **Dokploy stores and returns `secret` in cleartext.** The attribute is sensitive, so Terraform does not print it, but anyone with API access to the server can read it. The `secret_wo` companion keeps it out of the Terraform state.

## Example Usage

```terraform
# Register the OAuth application that you created in GitLab
# (User Settings > Applications, or a group application). GitLab needs the
# redirect URI that Dokploy reports back; the default matches the provider's
# endpoint, so most setups leave redirect_uri unset.
resource "dokploy_gitlab_provider" "main" {
  name           = "my-group"
  application_id = var.gitlab_oauth_application_id
  group_name     = "my-group"

  # Write-only: Terraform 1.11 or later. Change the version to send a new secret.
  secret_wo         = var.gitlab_oauth_secret
  secret_wo_version = 1
}

# After the apply, open Git > GitLab in Dokploy and authorize the
# application once. Until then the provider holds no access token.

# A self-hosted GitLab on a private network: gitlab_internal_url is the
# address that the Dokploy server uses to reach it.
resource "dokploy_gitlab_provider" "internal" {
  name                = "gitlab-internal"
  gitlab_url          = "https://gitlab.example.com"
  gitlab_internal_url = "http://10.0.0.5"
  application_id      = var.internal_oauth_application_id
  secret              = var.internal_oauth_secret
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `application_id` (String) Application ID of the OAuth application that you created in GitLab.
- `name` (String) Display name. Dokploy does not enforce a unique name.

### Optional

> **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later.

- `gitlab_internal_url` (String) URL that the Dokploy server uses to reach a self-hosted GitLab when it differs from `gitlab_url`, for example an address on a private network. If you remove it from the configuration, the provider clears it.
- `gitlab_url` (String) URL of the GitLab instance. Defaults to `https://gitlab.com`.
- `group_name` (String) GitLab group whose projects Dokploy lists. Omit it to list the projects of the authorizing user. If you remove it from the configuration, the provider clears it.
- `redirect_uri` (String) Redirect URI of the OAuth application. Defaults to `<endpoint>/api/providers/gitlab/callback`, built from the provider's `endpoint`. Register the same URI in GitLab.
- `secret` (String, Sensitive) Secret of the OAuth application. Set this attribute or `secret_wo`.
- `secret_wo` (String, Sensitive, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Write-only form of `secret`. Terraform keeps it out of the plan and the state. It needs Terraform 1.11 or later. Set exactly one of `secret` and `secret_wo`. A new value reaches the server only when `secret_wo_version` changes.
- `secret_wo_version` (Number) Version of `secret_wo`. Change it to send the current `secret_wo` value to the server. It needs `secret_wo`.

### Read-Only

- `created_at` (String) Creation timestamp from the server.
- `git_provider_id` (String) Id of the generic git-provider record that owns this GitLab record.
- `id` (String) The `gitlabId`. The `gitlab.gitlab_id` of an application or a compose references it.

## Import

Import is supported using the following syntax:

The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example:

```shell
# Import by the gitlabId, the id that gitlab.one takes.
terraform import dokploy_gitlab_provider.main c_59BSJGjfG2UAG-cima_
```