You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow wildcard matching of service account subject (#8629)
* Allow wildcard matching for service account subject
* Add subjectPattern property to iamserviceaccounts.md
* Remove misleading comment in iamserviceaccount.go
"description": "Subject pattern to use in the trust policy condition. When set, this pattern is used instead of the service account name, and StringLike is used instead of StringEquals to allow wildcard matching.",
981
+
"x-intellij-html-description": "Subject pattern to use in the trust policy condition. When set, this pattern is used instead of the service account name, and StringLike is used instead of StringEquals to allow wildcard matching."
982
+
},
978
983
"tags": {
979
984
"additionalProperties": {
980
985
"type": "string"
@@ -998,7 +1003,8 @@
998
1003
"status",
999
1004
"roleName",
1000
1005
"roleOnly",
1001
-
"tags"
1006
+
"tags",
1007
+
"subjectPattern"
1002
1008
],
1003
1009
"additionalProperties": false,
1004
1010
"description": "holds an IAM service account metadata and configuration",
fs.BoolVar(&overrideExistingServiceAccounts, "override-existing-serviceaccounts", false, "create IAM roles for existing serviceaccounts and update the serviceaccount")
59
59
60
+
fs.StringVar(&serviceAccount.SubjectPattern, "subject-pattern", "", "subject pattern to use in the trust policy (supports wildcards like '*' with StringLike condition)")
Copy file name to clipboardExpand all lines: userdocs/src/usage/iamserviceaccounts.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,50 @@ To update a service accounts roles permissions you can run `eksctl update iamser
91
91
???+ note
92
92
`eksctl delete iamserviceaccount` deletes Kubernetes `ServiceAccounts` even if they were not created by `eksctl`.
93
93
94
+
#### Using wildcard patterns with `--subject-pattern`
95
+
96
+
When you need to grant IAM permissions to multiple service accounts that follow a naming pattern, you can use the `--subject-pattern` flag to create an IAM role that trusts service accounts matching a wildcard pattern.
97
+
98
+
This is useful for scenarios such as:
99
+
- Multiple deployment replicas with dynamic service account names
100
+
- Applications that create service accounts with predictable prefixes
101
+
- Multi-tenant environments where service accounts share a naming convention
102
+
103
+
When using `--subject-pattern`, the IAM trust policy will use the `StringLike` condition operator instead of `StringEquals`, allowing wildcards like `*` to match multiple service accounts:
104
+
105
+
```console
106
+
eksctl create iamserviceaccount \
107
+
--cluster=<clusterName> \
108
+
--name=<serviceAccountName> \
109
+
--namespace=<serviceAccountNamespace> \
110
+
--attach-policy-arn=<policyARN> \
111
+
--subject-pattern="app-*"
112
+
```
113
+
114
+
For example, to allow all service accounts starting with `app-` in the `default` namespace to assume the role:
Use wildcard patterns carefully. A broad pattern like `*` would allow any service account in the namespace to assume the IAM role. Always use the most restrictive pattern possible for your use case.
135
+
136
+
The Subject Pattern property can be defined in the configuration file.
137
+
94
138
### Usage with config files
95
139
96
140
To manage `iamserviceaccounts` using config file, you will be looking to set `iam.withOIDC: true` and list account you want under `iam.serviceAccount`.
0 commit comments