title: aws sdk assumeRole not taking effect
body: <p>ive got the below segment of code running. My calls to aws work fine but now that ive had to switch roles its running into problems making it take effect as it seems im still stuck in the original role.</p>
  
  <pre><code>    public void awsAssumeRoleUsingEnvironmentVariable(Regions region, String roleARN, String roleSessionName) throws Exception {
          AWSSecurityTokenService stsClient = AWSSecurityTokenServiceClientBuilder.standard()
                  .withCredentials(new EnvironmentVariableCredentialsProvider())
                  .withRegion(region)
                  .build();
  
          GetCallerIdentityRequest request = new GetCallerIdentityRequest();
          GetCallerIdentityResult response = stsClient.getCallerIdentity(request);
  
          System.out.println("CURRENT ROLE ASSUMED IS: " + response.toString());
  
          request = new GetCallerIdentityRequest();
  
          System.out.println("EXECUTING ASSUME ROLE");
          AssumeRoleRequest roleRequest = new AssumeRoleRequest()
                  .withRoleArn(roleARN)
                  .withRoleSessionName(roleSessionName);
  
          AssumeRoleResult roleResponse = stsClient.assumeRole(roleRequest);
  
          Credentials sessionCredentials = roleResponse.getCredentials();
  
          response = stsClient.getCallerIdentity(request);
  
          System.out.println("CURRENT ROLE ASSUMED IS: " + response.toString());
      }
  </code></pre>
  
  <p>The getCallerIdentity is returning the same role each time</p>
  
  <p>Edit: 
  Just trying to work it out its definitely an issue with the way I've coded this up by trying to use the credentials returned using the AWSCLI. When I do a <code>System.out.println()</code> on the <code>sessionCredentials</code> variable produced when i run my app, and then manually export the returned keys using the below...</p>
  
  <pre><code>export AWS_ACCESS_KEY_ID=RoleAccessKeyID
  export AWS_SECRET_ACCESS_KEY=RoleSecretKey
  export AWS_SESSION_TOKEN=RoleSessionToken
  </code></pre>
  
  <p>Followed by a..</p>
  
  <p><code>aws sts get-caller-identity</code></p>
  
  <p>The correct role is returned, so my java code assumeRole seems to be working and getting credentials but its like Im not setting the client correctly so its not using the role its just assumed.</p>
  
  <p>Many thanks</p>