eks-token is a Python library that provides an alternative to the `aws eks get-token` CLI command, allowing programmatic generation of authentication tokens for Amazon EKS clusters. It is currently at version 0.3.0 and is actively maintained, with releases typically tied to feature enhancements or dependency updates.
pip install eks-tokenVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `eks-token` to retrieve an EKS authentication token. It shows basic usage with a cluster name and illustrates how to extract the actual token string. Ensure your AWS credentials are configured (e.g., via `~/.aws/credentials` or environment variables) and you have the necessary IAM permissions to interact with EKS. The `apiVersion` in the output now reflects `v1beta1` as of `eks-token` v0.2.0.
Ensure any Kubernetes client code consuming the output of `eks-token` is compatible with `client.authentication.k8s.io/v1beta1`. Most modern Kubernetes client libraries should support this.
Verify your AWS CLI is installed and configured correctly by running `aws sts get-caller-identity`. Ensure the IAM principal has permissions for `eks:DescribeCluster` and `sts:GetCallerIdentity` for the target EKS cluster.
Upgrade to `eks-token` version 0.1.4 or newer. This version fixed the issue by requiring a minimum AWS CLI version rather than an exact one, improving compatibility.
Refresh your AWS credentials. For AWS CLI, you might need to re-authenticate (e.g., `aws sso login` or renew your temporary credentials).
Grant `eks:DescribeCluster` permission to the IAM user or role. Additionally, ensure the principal has `sts:GetCallerIdentity` permission.
Ensure AWS credentials are configured. This can be done by setting environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`), configuring the AWS CLI (`aws configure`), or using an IAM role for EC2 instances/EKS pods.