title: getting credentials returned by AWS STS
body: <p>I am having an EC2 instance assigned to an instance profile. The instance profile have permission to assume a cross-account role (say, Account B)</p>
  
  <pre><code>aws sts assume-role --role-arn "arn:aws:iam::Account_B_ID:role/admin" 
  </code></pre>
  
  <p>--role-session-name "Admin_in_acc_B"</p>
  
  <p>by running this command, it will return a temporary security credentials including the session token. Now it comes to how to make use of the information to inject it into the environment variables so that the CLI will be able to run tasks (ec2-describe-instances) on Account B. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>export EC2_URL=https://ec2.ap-southeast-1.amazonaws.com
  export EC2_HOME=/usr/bin
  export JAVA_HOME=/usr/lib/jvm/default-java/jre
  
  export AWS_ACCESS_KEY=
  export AWS_SECRET_KEY=
  
  export AWS_SESSION_TOKEN=
  
  PATH=$PATH:/usr/bin
  
  ec2-describe-instances</code></pre>
  </div>
  </div>
  </p>