Skip to content

New Resource - gitlab_service_account

New Resource - gitlab_service_account

As introduced in 16.1 you can now create a service account user. In the API documentation there are currently 3 endpoints:

  • POST /groups/:id/service_accounts
  • POST /groups/:id/service_accounts/:user_id/personal_access_tokens
  • POST /groups/:id/service_accounts/:user_id/personal_access_tokens/:token_id/rotate

For these endpoints it would be nice to have resources that would look a little something like this:

resource "gitlab_group" "foo" {
  name = "foo-group"
  path = "foo-path"
}

resource "gitlab_service_account" "foo" {
  group = gitlab_group.foo.id  
}

resource "gitlab_service_account_personal_access_token" "foo" {
  group = gitlab_group.foo.id
  user  = gitlab_service_account.foo.id
}

resource "gitlab_service_account_personal_access_token_rotate" "foo" {
  group = gitlab_group.foo.id
  user  = gitlab_service_account.foo.id
  token = gitlab_service_account_personal_access_token.foo.id
}

Related GitLab APIs

API documentation:

Additional Details

Edited by Pascal Roose