This guide assumes you’ve already installed IAM Audit and configured the necessary AWS permissions.
Run Your First Audit
Verify Prerequisites
Ensure you have:
- Python 3.9+ installed
- boto3 package installed (
pip install boto3) - AWS CLI configured with a profile that has access to your AWS Organization management account
- Audit role deployed to all member accounts (e.g.,
AWSControlTowerExecutionor custom role)
Run the Audit
Execute the IAM audit script with your management account profile and the audit role name:What happens during execution:
- Control Tower
- Custom Role
If you’re using AWS Control Tower, use the pre-existing
AWSControlTowerExecution role:- Script lists all active accounts in your AWS Organization
- Assumes the audit role in each member account
- Collects IAM user data, access keys, MFA status, and login profiles
- Queries CloudTrail for recent IAM events
- Exports findings to two timestamped CSV files
Example console output
Example console output
Review the Reports
Two CSV files are generated with timestamps:1. IAM Audit Report (
2. CloudTrail Events Report (
iam_audit_report_YYYYMMDD_HHMMSS.csv)Contains detailed findings for each IAM user and access key:| Field | Description | Example |
|---|---|---|
account_id | AWS account ID | 123456789012 |
account_name | Account name from Organization | Production |
username | IAM user name | john.doe |
password_status | Console access configured | Configurada / No configurada |
password_last_used | Last console login date | 2026-03-04 15:30:00 |
access_key_id | Access key identifier | AKIAIOSFODNN7EXAMPLE |
status | Key status | Active / Inactive |
created_date | Key creation timestamp | 2018-06-15 10:20:30 |
last_used_date | Last time key was used | 2026-03-05 08:45:00 |
service_name | Last AWS service accessed | s3, ec2, sts, etc. |
mfa_status | MFA device type | Virtual / Hardware / None |
cloudtrail_events_YYYYMMDD_HHMMSS.csv)Tracks IAM-related events for remediation monitoring:| Field | Description |
|---|---|
eventTime | When the event occurred |
eventName | IAM action (CreateUser, DeleteAccessKey, etc.) |
username | User who performed the action |
account_id | Account where the event occurred |
account_name | Human-readable account name |
resources | Affected IAM resources |
Identify Security Issues
Open the IAM audit report and look for these red flags:Quick analysis in Excel or Numbers:
Old Access Keys
Keys created more than 90 days ago — potential security risk
Unused Keys
Keys that have never been used or haven’t been used in 6+ months
Missing MFA
Users with console access but no MFA device configured
Shared Credentials
Multiple active keys for a single user account
- Filter by
mfa_status = Noneandpassword_status = Configurada→ users with console access but no MFA - Sort by
created_dateascending → find the oldest access keys - Filter by
last_used_date = Nunca utilizada→ unused credentials to disable - Group by
usernamewith multiple rows → users with multiple active keys
What’s Next?
Configure Permissions
Fine-tune IAM policies for least-privilege access
Interpret Results
Learn how to analyze findings and assess risk
Remediate Issues
Step-by-step guide to fix identified security gaps
Automate Audits
Schedule recurring audits with AWS Lambda
Common Scenarios
Using AWS Control Tower
Using AWS Control Tower
Control Tower automatically deploys the Benefits:
AWSControlTowerExecution role to all enrolled accounts:- Zero configuration — role exists by default
- Automatically deployed to new accounts
- Permissions already configured for auditing
Custom Audit Role
Custom Audit Role
If you’re not using Control Tower or need a dedicated least-privilege role:Deploy the role to all member accounts using CloudFormation StackSets. See AWS Setup Guide.
Audit Failed for Some Accounts
Audit Failed for Some Accounts
If the audit role doesn’t exist in certain accounts, you’ll see errors like:This is expected behavior. The script continues auditing other accounts and skips those where the role isn’t available.To fix:
- Deploy the audit role to the missing accounts
- Verify the trust relationship allows your management account to assume the role
- Re-run the audit
No Access Keys Found
No Access Keys Found
If the report shows zero access keys:Possible causes:See Permissions Setup to review required IAM actions.
- ✅ Great job! Your organization may not have any IAM users with long-term credentials
- The audit role doesn’t have
iam:ListAccessKeyspermission - The role trust policy doesn’t allow your management account to assume it
