Bootstrap FreeKB - Amazon Web Services (AWS) - Remove IAM Policies from a Role using the AWS CLI
Amazon Web Services (AWS) - Remove IAM Policies from a Role 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-attached-user-policies command should list the policies that have been attached to a user.

The aws iam list-attached-role-policies command should list the policies that have been attached to a role.

In this example, the AdministratorAccess 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"
        }
    ]
}

 

  • The aws iam detach-user-policy command (this article) can be used to remove policies that have been attached to a user.
  • The aws iam detach-role-policy command (this article) can be used to remove policies that have been attached to a role.

In this example, the AdministratorAccess policy is removed from my-role.

aws iam detach-role-policy --role-name my-role --policy-arn arn:aws:iam::123456789012:policy/AdministratorAccess

 




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 9cfd41 in the box below so that we can be sure you are a human.