AWS CLI: List All Users in Account

Managing AWS IAM (Identity and Access Management) users is essential for maintaining security and proper control over your AWS environment. The AWS CLI provides a simple and easy way for us to list all users in your AWS Account, helping administrators monitor and manage access effectively.

This guide will show you how to use AWS CLI to retrieve IAM user details and filter the output for better readability.


How to List AWS IAM Users using Command

To retrieve a list of all IAM users in your AWS account, run the aws iam list-users command. This command returns a JSON-formatted list containing details such as usernames, ARNs, and creation dates.

To display specific user information, add the --query option as shown in the example below:

aws iam list-users --query "Users[*].{Name:UserName, ARN:Arn, Created:CreateDate}"
AWS CLI List Users

This will return a cleaner, more focused output, making it easier to review user details without unnecessary clutter.

Example output:

[
    {
        "Name": "AdminUser",
        "ARN": "arn:aws:iam::123456789012:user/AdminUser",
        "Created": "2022-04-15T12:34:56Z"
    },
    {
        "Name": "DeveloperUser",
        "ARN": "arn:aws:iam::123456789012:user/DeveloperUser",
        "Created": "2023-01-10T08:22:30Z"
    }
]

Additional IAM Commands

Here are some other useful IAM-related commands:

List IAM Roles:

aws iam list-roles

Get Details of a Specific IAM User:

aws iam get-user --user-name AdminUser

List IAM groups:

aws iam list-groups

List attached policies for a specific user:

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

For a full list of available IAM commands, refer to the official AWS CLI IAM Documentation.

Using AWS CLI to manage IAM users simplifies user administration. By filtering command output, you can quickly access the most relevant details without sifting through large JSON responses. You can always view this same information via the GUI (AWS Console), however using command-line for managing security is needed in larger organizations.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts
Categories
Tags

Always On Availability Groups (AAG) (4) AWS (4) AWS Redshift (6) Database Admin (72) Database Backups & Recovery (14) Database Mirroring (2) Error Messages (5) Failover Cluster Instances (FCI) (1) Git Commands (6) Importing & Exporting Data (2) Linked Servers (3) Linux Administration (2) Logging & Monitoring (1) Microsoft Patching (2) MySQL (4) Postgres (6) PowerShell Scripts (2) SQL Certificates & Encryption (3) SQL Server Agent (5) SQL Server CDC (2) SQL Server Data Types (2) SQL Server Management Studio (SSMS) (16) SQL Server Networking (3) SQL Server on Linux (1) SQL Server Patching (2) SQL Server Performance Tuning (6) SQL Server Processes (SPIDs) (7) SQL Server Replication (2) SQL Server Scripts (13) SQL Server Security (4) SQL Server Storage (10) Windows Admin (21) Windows Authentication (2) Windows Automation (1) Windows Events (2) Windows Firewall (4) Windows Subsystem for Linux (WSL) (18)