how to show an IAM user's roles with 'aws iam'?

If I run $ aws iam get-user --user-name anthony, I get result like this

{
    "User": {
        "Path": "/",
        "UserName": "anthony",
        "UserId": "E2S4XZIL9NRNSBIDBI5U6",
        "Arn": "arn:aws:iam::123456:user/anthony",
        "CreateDate": "2015-04-03T01:22:11Z",
        "PasswordLastUsed": "2019-04-10T01:38:14Z"
    }
}

If I want to get a list of role this login has, how can I do it with aws iam?


IAM User doesn't have IAM Roles, hence you can't list them.

IAM User can have IAM Policies (either attached directly or through IAM Group membership) that allow it to assume other roles.

You can list directly attached policies:

aws iam list-attached-user-policies --user-name ...

Group memberships:

aws iam list-groups-for-user --user-name ...

And from there groups policies:

aws iam list-attached-group-policies --group-name ... # group names from previous step

Hope that helps :)