cognitect-labs / aws-api

AWS, data driven
Apache License 2.0
730 stars 100 forks source link

Implement WebIdentityTokenCredentialsProvider and add it to default chain #133

Open kirillsalykin opened 4 years ago

kirillsalykin commented 4 years ago

Amazon has a new auth approach https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-core/src/main/java/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.java#L48

Would be nice to have it as well.

Thanks.

dchelimsky commented 4 years ago

To consider: the AWS documentation and implementation disagree about ordering.

kirillsalykin commented 4 years ago

Do you accept PRs?

dchelimsky commented 4 years ago

Do you accept PRs?

Sorry, no: https://github.com/cognitect-labs/aws-api#contributing

gws commented 3 years ago

Just noting that I am also interested in this feature, it looks like the documentation and SDKs have been updated to agree about the placement in the provider chain, and hopefully #164 (I missed this issue the first time around, whoops!) can help.

rodolfo42 commented 3 years ago

👋 Just noting we're also interested in getting this in the official lib, we need it so we can properly use EKS with WebIdentity for service account IAM roles (which is the recommended way from AWS).

For now we survived by incorporating the code from a gist from @gws (thanks for that - we kept your copyright notice)

NoahTheDuke commented 2 years ago

We'd love to use this library but this is currently show-stopper.

avocade commented 1 year ago

Ran into this issue as well today :D We'll add it to our custom credentials chain, but would be great of course if it could be included in the lib.

StankovicMarko commented 6 months ago

@rodolfo42 actually this piece of code saved me :) I was looking into it yesterday but couldn't figure it it never occurred to me to starts sts-client with empty credentials and also thanks to the @gws for making it.

It seems to be working well

cddr commented 2 months ago

I see the linked AWS docs and code now seem to agree. 3rd out of 6 in both places.

Screenshot 2024-09-03 at 13 56 02

itai-spiritt commented 4 days ago

I'm not sure if it's implemented or not, but I'm getting the error:

"Execution error (FileNotFoundException) at java.io.FileInputStream/open0 (FileInputStream.java:-2).\nclj (No such file or directory)\n",
 :clojure.main/triage
 {:clojure.error/class java.io.FileNotFoundException,
  :clojure.error/line -2,
  :clojure.error/cause "clj (No such file or directory)",
  :clojure.error/symbol java.io.FileInputStream/open0,
  :clojure.error/source "FileInputStream.java",
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.io.FileNotFoundException,
    :message "clj (No such file or directory)",
    :at [java.io.FileInputStream open0 "FileInputStream.java" -2]}],
  :trace
  [[java.io.FileInputStream open0 "FileInputStream.java" -2]
   [java.io.FileInputStream open "FileInputStream.java" 213]
   [java.io.FileInputStream <init> "FileInputStream.java" 152]
   [java.io.FileInputStream <init> "FileInputStream.java" 106]
   [clojure.lang.Compiler loadFile "Compiler.java" 7571]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$script_opt invokeStatic "main.clj" 535]
   [clojure.main$script_opt invoke "main.clj" 530]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "clj (No such file or directory)"}}

Inside my clj pod who is configured with service account and the correct env vars

AWS_STS_REGIONAL_ENDPOINTS : regional
AWS_WEB_IDENTITY_TOKEN_FILE : /var/run/secrets/eks.amazonaws.com/serviceaccount/token
AWS_ROLE_ARN : arn:aws:iam::***