Bootstrap FreeKB - Amazon Web Services (AWS) - List IAM Role Policies using the AWS CLI
Amazon Web Services (AWS) - List IAM Role Policies using the AWS CLI


This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.

The aws iam list-roles command can be used to list the IAM roles that have been created.

~]$ aws iam list-roles
{
    "Roles": [
        {
            "Path": "/",
            "RoleName": "my-role",
            "RoleId": "ARABCDITL71234TJARYZV",
            "Arn": "arn:aws:iam::123456789012:role/my-rolee",
            "CreateDate": "2023-07-18T06:08:58+00:00",
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "AWS": "arn:aws:iam::123456789012:root"
                        },
                        "Action": "sts:AssumeRole"
                    }
                ]
            },
            "MaxSessionDuration": 3600
        }
    ]
}

 

In this example, the ReadOnlyAccess policy is attached to my-role.

~]$ aws iam list-attached-role-policies --role-name my-role
{
    "AttachedPolicies": [
        {
            "PolicyName": "ReadOnlyAccess",
            "PolicyArn": "arn:aws:iam::aws:policy/ReadOnlyAccess"
        }
    ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 6c78e8 in the box below so that we can be sure you are a human.