File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed
modules/workload-identity Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ module "my-app-workload-identity" {
2020 name = "my-application-name"
2121 namespace = "default"
2222 project_id = "my-gcp-project-name"
23+ roles = ["roles/storage.Admin", "roles/compute.Admin"]
2324}
2425```
2526
@@ -75,6 +76,7 @@ module "my-app-workload-identity" {
7576| name | Name for both service accounts. The GCP SA will be truncated to the first 30 chars if necessary. | string | n/a | yes |
7677| namespace | Namespace for k8s service account | string | ` "default" ` | no |
7778| project\_ id | GCP project ID | string | n/a | yes |
79+ | roles | (optional) A list of roles to be added to the created Service account | list(string) | ` <list> ` | no |
7880| use\_ existing\_ k8s\_ sa | Use an existing kubernetes service account instead of creating one | bool | ` "false" ` | no |
7981
8082## Outputs
Original file line number Diff line number Diff line change @@ -64,3 +64,12 @@ resource "google_service_account_iam_member" "main" {
6464 role = " roles/iam.workloadIdentityUser"
6565 member = local. k8s_sa_gcp_derived_name
6666}
67+
68+
69+ resource "google_project_iam_member" "workload_identity_sa_bindings" {
70+ for_each = toset (var. roles )
71+
72+ project = var. project_id
73+ role = each. value
74+ member = " serviceAccount:${ google_service_account . cluster_service_account . email } "
75+ }
Original file line number Diff line number Diff line change @@ -59,3 +59,9 @@ variable "automount_service_account_token" {
5959 default = false
6060 type = bool
6161}
62+
63+ variable "roles" {
64+ type = list (string )
65+ default = []
66+ description = " (optional) A list of roles to be added to the created Service account"
67+ }
You can’t perform that action at this time.
0 commit comments