terraform-google-service-accounts
terraform-google-service-accounts copied to clipboard
Bug with prefix usage
TL;DR
Hello,
I am not able to create a ServicAccount without prefix
Error: "account_id" ("test") doesn't match regexp "^[a-z](?:[-a-z0-9]{4,28}[a-z0-9])$"
with module.service-accounts.google_service_account.service_accounts["test"],
on .terraform/modules/service-accounts/main.tf line 39, in resource "google_service_account" "service_accounts":
39: account_id = "${local.prefix}${lower(each.value)}"
Expected behavior
I should be able to create a SA without prefix
Default prefix variable is set to : ""
Observed behavior
No response
Terraform Configuration
tfvars :
project_id = "my-project"
region = "europe-west1"
names = ["test"]
project_roles = ["my-project=>roles/cloudsql.client",
"my-project=>roles/cloudsql.editor"]
description = ""
display_name = "test"
Module part :
module "service-accounts" {
source = "terraform-google-modules/service-accounts/google"
version = "v4.1.1"
names = var.names
project_id = var.project_id
description = var.description
display_name = var.display_name
prefix = var.prefix
}
### Terraform Version
```sh
1.2.7
hashicorp/google v4.38.0
Additional information
No response
I'm finding the same issue...
TL;DR
Hello,
I am not able to create a ServicAccount without prefix
Error: "account_id" ("test") doesn't match regexp "^[a-z](?:[-a-z0-9]{4,28}[a-z0-9])$" with module.service-accounts.google_service_account.service_accounts["test"], on .terraform/modules/service-accounts/main.tf line 39, in resource "google_service_account" "service_accounts": 39: account_id = "${local.prefix}${lower(each.value)}"
Expected behavior
I should be able to create a SA without prefix
Default prefix variable is set to : ""
Observed behavior
No response
Terraform Configuration
tfvars :
project_id = "my-project" region = "europe-west1" names = ["test"] project_roles = ["my-project=>roles/cloudsql.client", "my-project=>roles/cloudsql.editor"] description = "" display_name = "test"
Module part :
module "service-accounts" { source = "terraform-google-modules/service-accounts/google" version = "v4.1.1" names = var.names project_id = var.project_id description = var.description display_name = var.display_name prefix = var.prefix }
### Terraform Version ```sh 1.2.7 hashicorp/google v4.38.0
Additional information
No response
The problem is that the variable expects a hyphen as per regex validation but without a prefix there is no hyphen. If you set var.names each.value to have a hyphen the validation passes. The problem is, I can't find this validation anywhere in the code.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days