title: AWS Documentation on Java Assuming STS Client not working?
body: <p>As a prereq see <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/AuthUsingTempSessionTokenJava.html" rel="nofollow noreferrer">this</a> page.</p>
  
  <p>So I can created a small app that is literally a copy-paste of the code they provide. It does run for the given user, I have changed the global variables to the proper values, and I can assume the STS Role that I want via the AWS CLI. However this code will still not assume the proper role. </p>
  
  <p>I export the code as an executable jar, put it up onto my EC2 instance (basic AWS linux instance), and run it. I do have it output the keys from the STS Credentials which are proper and correct, but as soon as it gets down to the S3 client I get access denied (403).</p>
  
  <p>My roles are as follows:</p>
  
  <ul>
  <li>The EC2 has no role, but in the credentials file has a user access information (let's call him MyUser)</li>
  <li>MyUser has the ability to assume the STS role and IAM functionality (IAM functionality is not necessary, it's just for testing purposes)</li>
  <li>The STS role is assumable only by MyUser, and allows full access to S3 within the account</li>
  </ul>
  
  <p>AWS Documentation is hit or miss sometimes, but I can't find anyone else experiencing issues with this code. Like I said if I do the same process of assuming the STS role via CLI, I can do that and it works properly which makes this much more confusing.</p>
  
  <p>Thanks in advance to anyone who can help!</p>