Skip to content

Commit

Permalink
added service account var
Browse files Browse the repository at this point in the history
  • Loading branch information
amanpruthi committed Jun 10, 2024
1 parent 43d7c93 commit 9192760
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ module "wandb" {
install = true
stackdriver = {
projectId = data.google_client_config.current.project
serviceAccountName = var.service_account_name
}
serviceAccount = { annotations = { "iam.gke.io/gcp-service-account" = module.service_accounts.monitoring_role } }
} : {
Expand Down
4 changes: 2 additions & 2 deletions modules/service_accounts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ resource "google_project_iam_member" "secretmanager_admin" {

resource "google_service_account" "workload-identity-user-sa" {
count = var.enable_stackdriver == true ? 1 : 0
account_id = "stackdriver"
account_id = var.account_id
display_name = "Service Account For Workload Identity"
}

Expand All @@ -87,5 +87,5 @@ resource "google_service_account_iam_member" "workload_identity-role" {
count = var.enable_stackdriver == true ? 1 : 0
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[${var.namespace}/${var.service_account_name}]"
member = "serviceAccount:${local.project_id}.svc.id.goog[${var.stackdriver_namespace}/${var.service_account_name}]"
}
5 changes: 5 additions & 0 deletions modules/service_accounts/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ variable "service_account_name" {
variable "enable_stackdriver" {
description = "Flag to indicate whether to enable workload identity for the service account."
type = bool
}

variable "stackdriver_namespace" {
type = string
default = "default"
}
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ variable "enable_stackdriver" {

variable "workload_account_id" {
type = string
default = "stackdriver"
default = "wandb-stackdriver"
}

variable "service_account_name" {
type = string
default = "stackdriver"
default = "wandb-stackdriver"
}

0 comments on commit 9192760

Please sign in to comment.