library/src/main/java/com/kdgregory/aws/utils/iam/IAMUtil.java
/**
     *  Returns the current user's AWS account ID, null if unable to retrieve it
     *  (this indicates that the invoking user does not have valid credentials
     *  or is unable to connect to the Internet).
     */
Returns the current user's AWS account ID, null if unable to retrieve it
(this indicates that the invoking user does not have valid credentials
or is unable to connect to the Internet).
Returns the current user ' s AWS account ID null if unable to retrieve it ( this indicates that the invoking user does not have valid credentials or is unable to connect to the Internet ) .
public static String retrieveAccountId(AWSSecurityTokenService stsClient)
    {
        try
        {
            GetCallerIdentityRequest request = new GetCallerIdentityRequest();
            GetCallerIdentityResult response = stsClient.getCallerIdentity(request);
            return response.getAccount();
        }
        catch (Exception ignored)
        {
            return null;
        }
    }
public static String retrieveAccountId ( AWSSecurityTokenService stsClient ) { try { GetCallerIdentityRequest request = new GetCallerIdentityRequest ( ) ; GetCallerIdentityResult response = stsClient . getCallerIdentity ( request ) ; return response . getAccount ( ) ; } catch ( Exception ignored ) { return null ; } }
Returns the current user's AWS account ID, null if unable to retrieve it
  (this indicates that the invoking user does not have valid credentials
  or is unable to connect to the Internet).
Returns the current user ' s AWS account ID null if unable to retrieve it ( this indicates that the invoking user does not have valid credentials or is unable to connect to the Internet ) .