Actually, I use kubernetes service accounts mostly with NodeJS, and this works fine, but I have this one service made in Go and I can't seem to make it work with service accounts (I know that the service account is correctly configured because I tested it with a pod).
I'm using this lib https://github.com/aws/aws-sdk-go
Up till now I tried this:
sess := session.Must(session.NewSession())
creds := stscreds.NewCredentials(sess, os.Getenv("AWS_ROLE_ARN"))
svc := s3.New(sess, &aws.Config{Credentials: creds})
And also this (just in case):
region := os.Getenv("AMAZON_REGION")
sess := session.Must(session.NewSession(&aws.Config{Region: ®ion}))
svc := s3.New(sess)
for the first case I got the following error:
AccessDenied: User: arn:aws:sts::xxxxxxxx:assumed-role/staging-worker-node/i-0xxxxxxxxx is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::xxxxxxxx:role/EKSServiceAccount-app
and for the second case, I got a generic permission error.
I read the docs and tried a few things more (that may not be relevant here), but I can't see to make it work, maybe because I don't have much experience with golang.