Hi All,
Following is my use-case and looking for solution
variable sa_with_iam {
type = map(object({
display_name = string
description = string
roles = list(string)
}))
}
Now I will have to create multiple serviceaccount with each one having its own roles which can be more than one.
Something like
sa1 = {
display_name = "sa1"
description = "sa_1 description"
roles = ["storage.admin","iam.admin"]
}
sa2 = {
display_name = "sa2"
description = "sa_2 description"
roles = ["storage.read","iam.read"]
}
Following are the terraform for google_service_account and google_project_iam_member
resource "google_service_account" "service_account" {
account_id = "service-account-id"
display_name = "Service Account"
}
resource "google_project_iam_member" "project" {
project = "your-project-id"
role = "roles/editor"
member = "serviceAccount:myserviceaccount"
}