title: How can I get the credentials associated with the attached EC2 IAM role using the Java v2 SDK?
body: <p>In V1 SDK, we can use <code>EC2MetadataUtils.getIAMSecurityCredentials();</code> to get the temporary security credentials associated with the IAM roles on the instance.</p>
  <pre><code>Map&lt;String, EC2MetadataUtils.IAMSecurityCredential&gt; credMap = EC2MetadataUtils.getIAMSecurityCredentials();
  </code></pre>
  <p>What's the equivalent in the V2 SDK?</p>
  <p>I can't find anything in the dev guides or on Stack Overflow.</p>
  <p><a href="https://i.stack.imgur.com/kzC5w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kzC5w.png" alt="enter image description here" /></a></p>