-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.yaml
50 lines (50 loc) · 1.34 KB
/
role.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
apiVersion: iam.services.k8s.aws/v1alpha1
kind: Role
metadata:
name: my-role
spec:
assumeRolePolicyDocument: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Federated": "arn:aws:iam::00000000000:oidc-provider/my-oidc-url"
},
"Action": "sts:AssumeRoleWithWebIdentity",
"Condition": {
"StringLike": {
"my-oidc-url:aud": "sts.amazonaws.com",
"my-oidc-url:sub": "system:serviceaccount:my-namespace:my-service-account"
}
}
}
]
}
name: my-role
description: "Temporary K8s IAM Role"
inlinePolicies:
# There is a nice trick here, where we can use one role for multiple service accounts
# by using the aws:userid condition in the policy.
my-inline-policy: |
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:GetParameterHistory",
"ssm:GetParametersByPath",
"ssm:GetParameters",
"ssm:GetParameter",
"s3:*"
],
"Condition": {
"StringLike": {
"aws:userid":"*my-service-account*"
}
},
"Effect":"Allow","Resource":["*"]
}
]
}