Skip to content

Commit 8a23446

Browse files
committed
fix: added random number suffix to service_account_prefix local variable
1 parent 5275d76 commit 8a23446

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/instance_template/main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ locals {
7575
)
7676
create_service_account = var.create_service_account ? var.service_account == null : false
7777

78-
service_account_prefix = substr("${var.name_prefix}-${var.region}", 0, 27)
78+
service_account_prefix = "${substr("${var.name_prefix}-${var.region}", 0, 23)}-${random_integer.sa_suffix.result}"
7979
service_account_output = local.create_service_account ? {
8080
id = google_service_account.sa[0].account_id,
8181
email = google_service_account.sa[0].email,
8282
member = google_service_account.sa[0].member
8383
} : {}
8484
}
8585

86+
resource "random_integer" "sa_suffix" {
87+
min = 1000
88+
max = 9999
89+
}
90+
8691
# Service account
8792
resource "google_service_account" "sa" {
8893
provider = google-beta

0 commit comments

Comments
 (0)