Bootstrap FreeKB - Amazon Web Services (AWS) - Enable or Disable IAM users Access Key using the AWS CLI
Amazon Web Services (AWS) - Enable or Disable IAM users Access Key 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-users command can be used to list the IAM users that have been created.

~]$ aws iam list-users
{
    "Users": [
        {
            "Path": "/",
            "UserName": "john.doe",
            "UserId": "AIDAABCDL76GLUA6B21234",
            "Arn": "arn:aws:iam::123456789012:user/john.doe",
            "CreateDate": "2022-09-13T11:13:03+00:00"
        }
    ]
}

 

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

~]$ aws iam list-users
{
    "Users": [
        {
            "Path": "/",
            "UserName": "john.doe",
            "UserId": "AIDAABCDL76GLUA6B21234",
            "Arn": "arn:aws:iam::123456789012:user/john.doe",
            "CreateDate": "2022-09-13T11:13:03+00:00"
        }
    ]
}

 

The aws iam list-access-keys command can be used to list the access key ID associated with a user. Notice in this example that the Access Key is Active.

~]$ aws iam list-access-keys --user-name john.doe
{
    "AccessKeyMetadata": [
        {
            "UserName": "john.doe",
            "AccessKeyId": "AKIA2MABCD6GDQ1234RY",
            "Status": "Active",
            "CreateDate": "2022-09-13T11:13:04+00:00"
        }
    ]
}

 

The aws iam update-access-key command can be used to update a users Access Key to Active or Inactive.

The aws iam delete-access-key command can be used to delete an access key.

The aws iam create-access-key command can be used to create a new access key.

aws iam update-access-key --access-key-id AKIA2MABCD6GDQ1234RY --status Inactive --user-name john.doe

 

The aws iam update-access-key command is a bit strange in that no output will be returned so you will want to reissue the aws iam list-access-keys command. Notice in this example that the Access Key is now Inactive.

~]$ aws iam list-access-keys --user-name john.doe
{
    "AccessKeyMetadata": [
        {
            "UserName": "john.doe",
            "AccessKeyId": "AKIA2MABCD6GDQ1234RY",
            "Status": "Inactive",
            "CreateDate": "2022-09-13T11:13:04+00:00"
        }
    ]
}

 




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