AWS: How to assume role and set credentials to all consecutive client calls

151 views Asked by At

The case: Multitenant C++ application using AWS C++ SDK, it processes jobs that may belong to multiple tennats account and each time I should assume another role and make somehow our infra to work with new credentials, the problem that I cant start passing new credentials to zillion functions. I know how to assume role using AWS C++ SDK, but is it possible to set these credentials as default for all consecutive calls for all existing clients (S3Client, for example) on process/thread level?

1

There are 1 answers

0
Alexander Katsenelenbogen On

When you create a AWS-SDK client, you have the option to pass in an implementation of a credentials provider

  1. Your implementation of the credentials provider would basically use a AssumeRole provider.
  2. You can create a manual client cache which maps new AWS Clients to accounts, so you create a new one with the assume role provider once if it has not been created yet.
  3. To avoid having a thousand HTTP Clients sitting around, you can use configure all your SDK Client objects to use the same underlying client.