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" {
20
20
name = "my-application-name"
21
21
namespace = "default"
22
22
project_id = "my-gcp-project-name"
23
+ roles = ["roles/storage.Admin", "roles/compute.Admin"]
23
24
}
24
25
```
25
26
@@ -75,6 +76,7 @@ module "my-app-workload-identity" {
75
76
| name | Name for both service accounts. The GCP SA will be truncated to the first 30 chars if necessary. | string | n/a | yes |
76
77
| namespace | Namespace for k8s service account | string | ` "default" ` | no |
77
78
| 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 |
78
80
| use\_ existing\_ k8s\_ sa | Use an existing kubernetes service account instead of creating one | bool | ` "false" ` | no |
79
81
80
82
## Outputs
Original file line number Diff line number Diff line change @@ -64,3 +64,12 @@ resource "google_service_account_iam_member" "main" {
64
64
role = " roles/iam.workloadIdentityUser"
65
65
member = local. k8s_sa_gcp_derived_name
66
66
}
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" {
59
59
default = false
60
60
type = bool
61
61
}
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