gitlab_group_service_account_access_token no longer supports url encoded path for group attribute
Bug Report
When using the resource gitlab_group_service_account_access_token, the group attribute should and used to accept the ID or URL-encoded path of the group containing the service account. With the updates made in fix: user dedicated API to handle Group service... (!2793 - merged) , Terraform now errors when using the URL-encoded path as there was code added to use strconv.ParseInt on the parsed group id which will work for a group ID but not a group path.
The use of strconv.ParseInt on the group id (line 520) breaks the use of URL-encoded paths and is unnecessary when using the group ID number.
When using a URL-encoded group path, Terraform fails as the value cannot be parsed to an int.
When using the numerical group ID, the value is unnecessarily converted from string -> int -> string. This resource expects and stores the group ID as a string. When the group ID is passed to the go client via ListServiceAccountPersonalAccessTokens(), the value gets passed to parseID() which returns the ID as a string again to be passed to the endpoint groups/%s/service_accounts/%d/personal_access_tokens. Since ListServiceAccountPersonalAccessTokens() accepts the group ID as type any, the conversion to an INT beforehand is unnecessary.
Relevant Terraform Configuration
# The service account against the top-level group
resource "gitlab_group_service_account" "example_sa" {
group = "my-group"
name = "example-name"
username = "example-username"
}
resource "gitlab_group_service_account_access_token" "example_sa_token_rotation_configuration" {
group = "my-group"
user_id = gitlab_group_service_account.example_sa.service_account_id
name = "Example service account access token"
scopes = ["api"]
validate_past_expiration_date = false
rotation_configuration = {
rotate_before_days = 364
expiration_days = 14
}
}
Relevant Terraform Command
terraform plan
Relevant Log Output
Planning failed.Terraform encountered an error while generating this plan.
Error: Error parsing group ID
with gitlab_group_service_account_access_token.example_sa_token_rotation_configuration,
on service-account.tf line 18, in resource "gitlab_group_service_account_access_token" "example_sa_token_rotation_configuration":
18: resource "gitlab_group_service_account_access_token" "example_sa_token_rotation_configuration"
Could not parse group ID "my-group" to int: strconv.ParseInt:
parsing "my-group": invalid syntax
Additional Details
- GitLab Terraform Provider Version: `18.8.0`
- GitLab Instance Version: `SaaS`
- Terraform Version: `1.14.2`
- License Tier:
Ultimate