The gitlab_personal_access_token
resource allows to manage the lifecycle of a personal access token for a specified user.
Upstream API: GitLab REST API docs
resource "gitlab_personal_access_token" "example" {
user_id = "25"
name = "Example personal access token"
expires_at = "2020-03-14"
scopes = ["api"]
}
resource "gitlab_project_variable" "example" {
project = gitlab_project.example.id
key = "pat"
value = gitlab_personal_access_token.example.token
}
expires_at
(String) The token expires at midnight UTC on that date. The date must be in the format YYYY-MM-DD.name
(String) The name of the personal access token.scopes
(Set of String) The scope for the personal access token. It determines the actions which can be performed when authenticating with this token. Valid values are: api
, read_user
, read_api
, read_repository
, write_repository
, read_registry
, write_registry
, sudo
, admin_mode
, create_runner
.user_id
(Number) The id of the user.active
(Boolean) True if the token is active.created_at
(String) Time the token has been created, RFC3339 format.id
(String) The ID of this resource.revoked
(Boolean) True if the token is revoked.token
(String, Sensitive) The personal access token. This is only populated when creating a new personal access token. This attribute is not available for imported resources.Import is supported using the following syntax:
# A GitLab Personal Access Token can be imported using a key composed of `<user-id>:<token-id>`, e.g.
terraform import gitlab_personal_access_token.example "12345:1"
# NOTE: the `token` resource attribute is not available for imported resources as this information cannot be read from the GitLab API.