Skip to content

Latest commit

 

History

History
 
 

chainrole

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Role chaining extension

This extensions allows to use Role Chaining to Assume different role before sharing credentials with requesting container.

Why

This functionality will enable following features:

How

In addition to normal AssumeRoleForPodIdentity logic, extensions adds following logic:

  1. Get Namespace and Serviceaccount name from JWT token

  2. Check them against --chainrole-namespace-pattern and --chainrole-service-account-pattern provided regexps

    • In case of no match, stop custom logic and proceed with normal flow
  3. Call DescribePodIdentityAssociation using Pod Identity role to get PodIdentityAssociation tags. ⚠️ See example permissions for Pod Identity role ⚠️

      {
        "Sid" : "EKSDescribePodIdentities",
        "Effect" : "Allow",
        "Action" : "eks:DescribePodIdentityAssociation",
        "Resource" : "arn:aws:eks:*:123456789012:podidentityassociation/$${aws:PrincipalTag/eks-cluster-name}/*",
      }
  4. Based on the tags with prefix assume-role.ekspia.go.amzn.com prepare parameters for AssumeRole call

    Example command to create Pod Identity Association with required tags:

    aws eks create-pod-identity-association --cluster-name my-test-cluster --namespace test-pod-identity  --service-account new-test-sa --role-arn arn:aws:iam::123456789012:role/my-pod-role --region us-west-2 --tags '{
        "assume-role.ekspia.go.amzn.com/role-arn": "arn:aws:iam::123456789012:role/my-new-role",
        "assume-role.ekspia.go.amzn.com/role-session-name": "my-session-name",
        "assume-role.ekspia.go.amzn.com/session-duration": "900s",
        "assume-role.ekspia.go.amzn.com/session-tag/tag1": "value1",
        "assume-role.ekspia.go.amzn.com/session-tag/tag2": "value2"
    }'

    See tagsToSTSAssumeRole in chainrole.go to see list of supported params

  5. AssumeRole using EKS Pod Identity Agent's permissions:

  6. Return credentials (where they will get cached and returned to requester)