Prerequisites
Before running an audit, ensure you have:AWS CLI Configured
An AWS CLI profile configured with access to your management accountOr verify existing profiles:
Basic Execution
The audit requires two mandatory flags:Common Examples
What Happens During Execution
When you run the audit, the tool performs these operations in sequence:List Organization Accounts
Connects to AWS Organizations API using your management account credentials to retrieve all ACTIVE accounts
CloudTrail Events Collection
Before auditing IAM, the tool queries CloudTrail events across all accounts for the following IAM-related events:
CreateUserDeleteUserCreateAccessKeyDeleteAccessKeyDeleteLoginProfile
iam_audit.py:137)Assume Role in Each Account
For each account, the tool:
- Calls
sts:AssumeRoleto obtain temporary credentials - Creates an IAM client with the temporary credentials
- Uses session name
SecurityAudit
Collect Access Key Data
For each user, the tool retrieves:
- All access keys (active and inactive)
- Access key last used date and service
- MFA device status (None, Virtual, or Hardware)
- Login profile status (console password configured or not)
- Password last used date
Monitoring Progress
The tool outputs progress messages to the console:Execution Time Estimates
Execution time varies based on organization size:| Organization Size | Estimated Time |
|---|---|
| 5-10 accounts | 2-5 minutes |
| 10-20 accounts | 5-10 minutes |
| 20-50 accounts | 10-20 minutes |
| 50+ accounts | 20+ minutes |
Time estimates assume ~10-50 IAM users per account. Organizations with hundreds of IAM users per account will take longer.
Common Errors and Quick Fixes
Error: An error occurred (AccessDenied) when calling the AssumeRole operation
Error: An error occurred (AccessDenied) when calling the AssumeRole operation
Cause: The audit role doesn’t exist in a member account, or the trust policy doesn’t allow the management account to assume it.Fix:
- Verify the role exists in the member account
- Check the trust policy allows
sts:AssumeRolefrom your management account - Ensure the role name matches exactly (case-sensitive)
The tool will skip accounts where it can’t assume the role and continue with others. Check console output for which accounts failed.
Error: An error occurred (NoSuchEntity) when calling the GetLoginProfile operation
Error: An error occurred (NoSuchEntity) when calling the GetLoginProfile operation
Cause: This is expected behavior when a user doesn’t have console access configured.Fix: No action needed. The code handles this exception and sets
password_status to “No configurada” (see iam_audit.py:58).Error: botocore.exceptions.NoCredentialsError
Error: botocore.exceptions.NoCredentialsError
Cause: AWS credentials not configured or the specified profile doesn’t exist.Fix:
Error: An error occurred (AccessDeniedException) when calling the ListAccounts operation
Error: An error occurred (AccessDeniedException) when calling the ListAccounts operation
Cause: Your profile doesn’t have
organizations:ListAccounts permission.Fix: Ensure your management account credentials include:No output files generated
No output files generated
Cause: No IAM users with access keys were found, or all accounts failed to audit.Fix:
- Check console output for error messages
- Verify the role exists in at least one member account
- Confirm there are IAM users in your accounts
Next Steps
After running the audit successfully:Understand Reports
Learn what each CSV field means and how to analyze the output
Command Reference
Explore all available command-line options
