title: From AWS SDK, how to I get the current logged in username (or IAM user)?
body: <p>I'm using the Ruby SDK (V2), but I guess my question is more general than the specific implementation as I couldn't find an answer in any of the SDKs.</p>
  
  <p>How do I get the username (and/or IAM user) that my session currently belongs to?</p>
  
  <p>I let the SDK run its default behaviour for choosing credentials (ENV vars, then 'default' profile or other if specified and then machine role). Then I initialize my client and run commands. I'd like to know 'who is running the commands'. I expect to get the AWS username and if the chosen credentials were of an IAM user in it, then this username too.</p>
  
  <p>Any ideas?
  The best I got so far was that after I build a <code>Client</code> object, I can query it's actual <code>config</code> and get <code>Credentials</code>. But that only gives me what credentials were chosen (i.e. <code>SharedCredentials profile='default'</code> vs. <code>Credentials key=.. secret=..</code>) and doesn't tell me who is the username behind it.</p>
  
  <p>Many thanks!</p>