Skip to content
/ eksx Public

AWS EKS utility library for getting a token to access your EKS cluster

License

Notifications You must be signed in to change notification settings

MrBergin/eksx

Repository files navigation

TeamCity Full Build Status

EksX

AWS EKS utility library born out of a need to replicate the following functionality, but without relying on the command line:

https://awscli.amazonaws.com/v2/documentation/api/latest/reference/eks/get-token.html

Heavily inspired from the wonderful answer I found on this topic here:

https://stackoverflow.com/questions/59853623/get-authentication-token-from-aws-eks-using-the-aws-java-sdk-v2

Example Gradle usage:

repositories {
    mavenCentral()
}
dependencies {
    implementation("dev.mrbergin:eksx:0.0.1")
}

Example Usage:

val eksx = AwsEksX(
    accessKeyId = yourAccessKeyId,
    secretAccessKey = yourSecretAccessKey,
    region = yourRegion,
)

val token = eksx.getToken(
    clusterName = yourClusterName,
    roleArn = yourRoleArn, //optional
)

//use the token with your favourite K8s client!

For further examples (including Java, if you're into that) see the examples folder

You have no tests, what kind of dev are you?!

I found the effort to value ratio unappealing. The logic in this code is mostly just stitching together a bunch of AWS APIs, and the unit tests I started writing were a monstrosity of white box testing mocks which I'm not a fan of...

I wanted to write some integration tests with docker and localstack, but it appears EKS is only available with the pro version of localstack, so I just decided to write examples and test them against a real EKS cluster instead.

PRs that educate me on how this could actually be unit / integration tested are welcome!

About

AWS EKS utility library for getting a token to access your EKS cluster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages