From 08abe848938ba80d48c2e747b5e9f229dd01eda4 Mon Sep 17 00:00:00 2001 From: Aman Pruthi Date: Fri, 7 Jun 2024 23:40:54 +0530 Subject: [PATCH] feat: Track the otel and stackdriver sa issue (#134) * feat: added support for stackdriver and otel metrics * fixed checks * fixed tmp service account issue * fixed lint * fixed sa issue --------- Co-authored-by: amanpruthi --- modules/service_accounts/main.tf | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/service_accounts/main.tf b/modules/service_accounts/main.tf index ca85630e..3dc03374 100644 --- a/modules/service_accounts/main.tf +++ b/modules/service_accounts/main.tf @@ -67,20 +67,25 @@ resource "google_service_account" "workload-identity-user-sa" { count = var.enable_stackdriver == true ? 1 : 0 account_id = "stackdriver" display_name = "Service Account For Workload Identity" - } resource "google_project_iam_member" "monitoring-role" { count = var.enable_stackdriver == true ? 1 : 0 project = local.project_id role = "roles/monitoring.viewer" - member = "serviceAccount:${google_service_account.workload-identity-user-sa[count.index].email}" + member = "serviceAccount:${google_service_account.workload-identity-user-sa[count.index].email}" } +resource "google_service_account_iam_member" "monitoring-role" { + count = var.enable_stackdriver == true ? 1 : 0 + service_account_id = google_service_account.workload-identity-user-sa[count.index].id + role = "roles/iam.serviceAccountTokenCreator" + member = "serviceAccount:${google_service_account.workload-identity-user-sa[count.index].email}" +} -resource "google_project_iam_member" "workload_identity-role" { +resource "google_service_account_iam_member" "workload_identity-role" { count = var.enable_stackdriver == true ? 1 : 0 - project = local.project_id + service_account_id = google_service_account.workload-identity-user-sa[count.index].id role = "roles/iam.workloadIdentityUser" member = "serviceAccount:${local.project_id}.svc.id.goog[default/${var.service_account_name}]" } \ No newline at end of file