1. Log in to AWS Console.
2. Click the Cloudshell icon at the top right hand side of the page.
3. When using Azure SSO run this command:
aws sts assume-role --role-arn arn:aws:iam::placeyouraccountnumberhere:role/addYourCurrentlyRole --role-session-name "RoleSession1"
4. Export the Temporary AccessKey in your local CLI
export AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_SESSION_TOKEN=AQoDYXdzEJr...<remainder of security token>
5. Test the Temporary AccessKey on your local CLI:
aws ec2 describe-instances --region ap-southeast-2 aws sts get-caller-identity
Reference: