Bootstrap FreeKB - Amazon Web Services (AWS) - Remove IAM Policies from a User using the AWS CLI
Amazon Web Services (AWS) - Remove IAM Policies from a User 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 user john.doe.

~]$ aws iam list-attached-user-policies --user-name john.doe
{
    "AttachedPolicies": [
        {
            "PolicyName": "AdministratorAccess",
            "PolicyArn": "arn:aws:iam::aws:policy/AdministratorAccess"
        }
    ]
}

 

  • 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 can be used to remove policies that have been attached to a role.

In this example, the AdministratorAccess policy is removed from user john.doe.

aws iam detach-user-policy --user-name john.doe --policy-arn arn:aws:iam::aws: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 eb0a76 in the box below so that we can be sure you are a human.