Skip to content

Commit f4a7999

Browse files
committed
chore: update service_account_id output variable
1 parent b8510ac commit f4a7999

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

modules/instance_template/main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
# Locals
1919
#########
2020

21+
data "google_service_account" "existing_sa" {
22+
count = local.create_service_account == false ? 1 : 0
23+
account_id = element(split("@", google_cloud_run_v2_service.main.template[0].service_account), 0)
24+
project = element(split("@", element(split(".", google_cloud_run_v2_service.main.template[0].service_account), 0)), 1)
25+
}
26+
2127
locals {
2228
source_image = var.source_image != "" ? var.source_image : "rocky-linux-9-optimized-gcp-v20240111"
2329
source_image_family = var.source_image_family != "" ? var.source_image_family : "rocky-linux-9-optimized-gcp"
@@ -80,7 +86,11 @@ locals {
8086
id = google_service_account.sa[0].account_id,
8187
email = google_service_account.sa[0].email,
8288
member = google_service_account.sa[0].member
83-
} : {}
89+
} : {
90+
id = data.google_service_account.existing_sa[0].account_id,
91+
email = data.google_service_account.existing_sa[0].email,
92+
member = data.google_service_account.existing_sa[0].member
93+
}
8494
}
8595

8696
# Service account

0 commit comments

Comments
 (0)