I use the Ruby SDK (V2), but I think my question is more general than the specific implementation, since I could not find the answer in any of the SDKs.
How do I get the username (and / or IAM user) to which my session belongs?
I allow the SDK to perform the default behavior for selecting credentials (ENV vars, then the default profile or another, if specified, and then the role of the machine). Then I initialize my client and run the commands. I would like to know who executes the commands. I expect to get an AWS username, and if IAM user credentials are listed, this is also the username.
Any ideas? The best thing that I have received so far is that after creating the Client object, I can request its actual config and get the Credentials . But that only gives me what credentials were selected (i.e. SharedCredentials profile='default' vs. Credentials key=.. secret=.. ) and doesn't tell me who his name is.
Many thanks!
amazon-web-services amazon-iam aws-sdk
Zach moshe
source share