Skip to content

Commit

Permalink
Added customer name as a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
amanpruthi committed Jul 11, 2024
1 parent 20935bb commit 3c4f2be
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module "service_accounts" {
create_workload_identity = var.create_workload_identity
stackdriver_sa_name = var.stackdriver_sa_name
enable_stackdriver = var.enable_stackdriver
customer_name = var.customer_name
depends_on = [module.project_factory_project_services]
}

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" {
####### service account for kms and gcs cross project access
resource "google_service_account" "kms_gcs_sa" {
count = var.create_workload_identity == true ? 1 : 0
account_id = substr("kms-gcs-${random_id.main.hex}", 0, 30)
account_id = substr("kms-gcs-${var.customer_name}-${random_id.main.hex}", 0, 30)
display_name = "Service Account For Workload Identity"
}

Expand Down Expand Up @@ -132,7 +132,7 @@ resource "google_service_account_iam_member" "workload_binding" {
### service account for stackdriver
resource "google_service_account" "stackdriver" {
count = var.enable_stackdriver == true ? 1 : 0
account_id = substr("stackdriver-${random_id.main.hex}", 0, 30)
account_id = substr("stackdriver-${var.customer_name}-${random_id.main.hex}", 0, 30)
display_name = "Service Account For Workload Identity"
}

Expand Down
4 changes: 4 additions & 0 deletions modules/service_accounts/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ variable "enable_stackdriver" {
description = "Flag to indicate whether to enable workload identity for the service account."
type = bool
}

variable "customer_name" {
type = string
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,8 @@ variable "stackdriver_sa_name" {
default = "wandb-stackdriver"
}

variable "customer_name" {
description = "Customer name for identifying service accounts"
type = string
default = "wandb"
}

0 comments on commit 3c4f2be

Please sign in to comment.