EKS Token package, an alternate to "aws eks get-token ..." CLI
pip install eks-token
from eks_token import get_token
from pprint import pprint
response = get_token(cluster_name='<value>')
pprint(response)
Expected Output
{'apiVersion': 'client.authentication.k8s.io/v1alpha1',
'kind': 'ExecCredential',
'spec': {},
'status': {'expirationTimestamp': '2020-10-01T15:05:17Z',
'token': 'k8s-aws-v1.<token_value>'}}
from eks_token import get_token
token = get_token(cluster_name='value')['status']['token']
print(token)
Pass role_arn
argument to the function
from eks_token import get_token
token = get_token(cluster_name='<value>', role_arn='<value>')['status']['token']
print(token)
Check our guidelines here