Generate EKS token with signature v4 signing process.
npm install aws-eks-token
1. Generation with default credential file, we will read your credentials in an effective way, the config of aws-eks-token depends on aws-sdk's implementation.
const EKSToken = require('aws-eks-token');
EKSToken.renew('cluster-name').then(token => {
console.log(token);
});
If more than one credential source is available to the SDK, the default precedence of selection is as follows:
- Credentials that are explicitly set through the service-client constructor
- Environment variables
- The shared credentials file
- Credentials loaded from the ECS credentials provider (if applicable)
- Credentials that are obtained by using a credential process specified in the shared AWS config file or the shared credentials file. For more information, see Loading Credentials in Node.js using a Configured Credential Process.
- Credentials loaded from AWS IAM using the credentials provider of the Amazon EC2 instance (if configured in the instance metadata)
For more information, see Class: AWS.Credentials and Class: AWS.CredentialProviderChain in the API reference.
EKSToken.config = {
accessKeyId: 'AKID',
secretAccessKey: 'SECRET',
region: 'us-west-2'
};
EKSToken.renew('eks-cluster', '60', '20200930T093726Z');