Skip to content

Commit

Permalink
feat: Track the otel and stackdriver sa issue (#134)
Browse files Browse the repository at this point in the history
* feat: added support for stackdriver and otel metrics

* fixed checks

* fixed tmp service account issue

* fixed lint

* fixed sa issue

---------

Co-authored-by: amanpruthi <aman.pruthi@velotio.com>
  • Loading branch information
amanpruthi and amanpruthi authored Jun 7, 2024
1 parent 255a7f1 commit 08abe84
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/service_accounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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}]"
}

0 comments on commit 08abe84

Please sign in to comment.