Find out which role is used when an AWS CLI command is called

This is very useful if you are running an AWS command on an ec2 instance which is using an IAM role or instance profile and you would like to verify if it is using the intended role.

aws sts get-caller-identity

$ aws sts get-caller-identity
{
    "Account": "0123456789",
    "UserId": "ABCDxxx:i-abc123",
    "Arn": "arn:aws:sts::0123456789:assumed-role/ECS_Opsworks_DefaultRole/i-abc123"
}