1

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?

Tennis Smith
  • 451
  • 6
  • 14
  • I assume it would work if the host that you are running the code has a kubeconfig and you use `const kc = new k8s.KubeConfig(); kc.loadFromDefault();` kubernetes clients have no knowledge of aws credentials – Furkan Jul 21 '22 at 11:29
  • @Furkan Ok. Put another way, how would I pass these as environment variables? – Tennis Smith Jul 21 '22 at 13:34
  • to the client? you can't. For the node application `process.env.ENV_NAME` – Furkan Jul 21 '22 at 14:09
  • @Furkan so, you're saying that there is no way to pass env var data to the client, but you *can* to the node application using the client? – Tennis Smith Jul 21 '22 at 16:52

1 Answers1

0

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

  • 1
    Thanks, but that's not what I'm looking for. :) I need to pass those values *inside* the api. I cannot rely on them being set in the shell environment. – Tennis Smith Jul 21 '22 at 16:54