gitlab_deploy_token (Resource)

The gitlab_deploy_token resource allows to manage the lifecycle of group and project deploy tokens.

Upstream API: GitLab REST API docs

Example Usage

# Example Usage - Project
resource "gitlab_deploy_token" "example" {
  project    = "example/deploying"
  name       = "Example deploy token"
  username   = "example-username"
  expires_at = "2020-03-14T00:00:00.000Z"

  scopes = ["read_repository", "read_registry"]
}

resource "gitlab_deploy_token" "example-two" {
  project    = "12345678"
  name       = "Example deploy token expires in 24h"
  expires_at = timeadd(timestamp(), "24h")
}

# Example Usage - Group
resource "gitlab_deploy_token" "example" {
  group = "example/deploying"
  name  = "Example group deploy token"

  scopes = ["read_repository"]
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

# GitLab deploy tokens can be imported using an id made up of `{type}:{type_id}:{deploy_token_id}`, where type is one of: project, group.
terraform import gitlab_deploy_token.group_token group:1:3
terraform import gitlab_deploy_token.project_token project:1:4

# Note: the `token` resource attribute is not available for imported resources as this information cannot be read from the GitLab API.