Problem to solve
Using the terraform resource gitlab_project_access_token to create an access token for a newly created project requires a personal access token. When I created a group access token with owner role and api scope, an auth error is returned. If I use the personal access token, it succeeds. In the below block, if the gitlab_token is a PAT it works. If it is a group access token it fails.
Blockquote
gitlab = {
source = “gitlabhq/gitlab”
version = “~> 17.4.0”
}
provider “gitlab” {
token = var.gitlab_token
}
resource “gitlab_project” “component_terraform_repo” {
name = “${var.gitlab_component_repo}”
description = “DO NOT EDIT. IaC managed.”
namespace_id = var.gitlab_group_id
visibility_level = “private”
}
resource “gitlab_project_access_token” “component_access_token” {
project = gitlab_project.component_terraform_repo.id
name = “${var.gitlab_component_repo}-full-access-token”
scopes = [“api”, “read_repository”, “write_repository”]
expires_at = “2025-10-13”
}