How to pass AWS credentials to Kubernetes Javascript client?

315 views Asked by At

I have inherited some Javascript code that creates a client and then does a namespace query on an EKS cluster:

   //Get API client for k8s
    let k8sApplicationAPI = this.kubeConfig.makeApiClient(k8s.AppsV1Api);
    //Get deployments
    k8sApplicationAPI.listNamespacedDeployment(namespaceName)

How do I pass the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to the client?

Or, more accurately, how do I pass these needed environment variables to the client?

1

There are 1 answers

1
Kevin Mullin On

You need to configure the aws credential file probably. It exists here ~/.aws/credentials

$ aws configure
AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE
AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Default region name [None]: us-west-2
Default output format [None]: json

This will run you through a cli wizard and it creates that file which gets used by the client.

https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html