aws / containers-roadmap

This is the public roadmap for AWS container services (ECS, ECR, Fargate, and EKS).
https://aws.amazon.com/about-aws/whats-new/containers/
Other
5.22k stars 321 forks source link

[EKS] [request]: Ability to extract substring from ${OIDC_PROVIDER}:sub variable when using IRSA #1512

Open yarozen opened 3 years ago

yarozen commented 3 years ago

Community Note

Tell us about your request Ability to extract substring from ${OIDC_PROVIDER}:sub variable when using IRSA

Which service(s) is this request for? EKS

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? I want to provide each pod with access to specific folder in S3 bucket where the folder name is automatically derived from the identity of the pod or service account name that is assigned to the pod. This way I can use a single role & policy without the need to create them per pod. when using the ${OIDC_PROVIDER}:sub variable in IAM policy associated with the assumed role, the returned value looks like this system:serviceaccount:<my-namespace>:<my-service-account>. So all the folder names will have to have this structure. If I was able to obtain just the namespace or the service account I was able to name the S3 folders like I initially wanted. If I could obtain a substring of the sub variable that would have been great. something like this:

"${OIDC_PROVIDER}:sub": "system:serviceaccount:<my-namespace>:<my-service-account>"
"${OIDC_PROVIDER}:sub:namespace": "<my-namespace>"
"${OIDC_PROVIDER}:sub:serviceaccount": "<my-service-account>"

Are you currently working around this issue? I need to create a dedicated role and policy per service account

oshmyrko commented 2 years ago

It would be really nice to have such key in AWS global condition context keys. Currently there are only aws:FederatedProvider key, which only allows to limit access to AWS services like S3 by identity provider ARN.

peleduri commented 2 years ago

+1

popen2 commented 1 year ago

Would it be possible to maybe add this information to the session tags of the assumed role session? References:

There could be default session tags added automatically by EKS, or allow service account annotations to inject this information. For example this service account:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: example
  namespace: example
  annotations:
    eks.amazonaws.com/role-arn: <role-arn>
    eks.amazonaws.com/session-tag/Tenant:ID Tenant1
    eks.amazonaws.com/session-tag/Env: Staging

the ${aws:PrincipalTag/TenantID} and ${aws:PrincipalTag/Env} variables would be usable in the attached role policy.