Overview
The tool generates two CSV files with timestamps in the current working directory:IAM Audit Report
iam_audit_report_YYYYMMDD_HHMMSS.csvComplete inventory of IAM users, access keys, MFA status, and console accessCloudTrail Events
cloudtrail_events_YYYYMMDD_HHMMSS.csvRecent IAM user and access key lifecycle events for remediation trackingIAM Audit Report CSV
File Structure
Filename:iam_audit_report_YYYYMMDD_HHMMSS.csvSource:
iam_audit.py:176-183
Each row represents one access key for an IAM user. Users with multiple access keys will appear in multiple rows.
CSV Fields
The IAM audit report contains 11 columns extracted from theget_iam_users_with_keys function (iam_audit.py:70-82):
AWS account ID (12 digits)Example:
123456789012Human-readable account name from AWS OrganizationsExample:
Production, Staging, DevelopmentIAM user nameExample:
admin, [email protected], ci-deploy-userConsole password configuration statusValues:
Configurada- User has console access enabledNo configurada- User does not have console access
iam_audit.py:54-58 (calls GetLoginProfile API)Last time the user signed into the AWS Management ConsoleExample:
If never used:
2026-03-01 14:23:15+00:00If never used:
NuncaSource: iam_audit.py:75 (from User.PasswordLastUsed attribute)Access key IDExample:
AKIAIOSFODNN7EXAMPLEAccess key statusValues:
Active- Key is currently active and can be usedInactive- Key is disabled
iam_audit.py:77 (from AccessKeyMetadata.Status)Date and time when the access key was createdExample:
2023-08-15 10:32:45+00:00Source: iam_audit.py:78 (from AccessKeyMetadata.CreateDate)Last time the access key was used to make an AWS API requestExample:
If never used:
2026-03-04 08:15:30+00:00If never used:
Nunca utilizadaSource: iam_audit.py:79 (from GetAccessKeyLastUsed API)AWS service where the access key was last usedExample:
If never used:
s3, ec2, sts, dynamodbIf never used:
N/ASource: iam_audit.py:80 (from GetAccessKeyLastUsed.ServiceName)Multi-factor authentication device status for the userValues:
Virtual- Virtual MFA device (authenticator app)Hardware- Hardware MFA deviceNone- No MFA device configured
iam_audit.py:45-52 (from ListMFADevices API)Example CSV Output
CloudTrail Events CSV
File Structure
Filename:cloudtrail_events_YYYYMMDD_HHMMSS.csvSource:
iam_audit.py:200-208
Each row represents one CloudTrail event related to IAM user or access key lifecycle.
CSV Fields
The CloudTrail events report contains 6 columns extracted from theget_cloudtrail_events function (iam_audit.py:109-116):
Timestamp when the event occurredExample:
2026-02-28 15:32:10+00:00Name of the IAM API actionTracked Events:
CreateUserDeleteUserCreateAccessKeyDeleteAccessKeyDeleteLoginProfile
iam_audit.py:88 (hardcoded list)IAM principal who performed the actionExample:
If unavailable:
[email protected], AWSControlTowerExecutionIf unavailable:
N/ASource: iam_audit.py:112 (from Event.Username)AWS account ID where the event occurredExample:
123456789012Human-readable account nameExample:
Production, StagingComma-separated list of affected resource namesExample:
AKIAIOSFODNN7EXAMPLE, contractor-tempSource: iam_audit.py:207 (converted from array to comma-separated string)Example CSV Output
Time Range
Analyzing the Reports
Using Excel
Using Python (pandas)
Using AWS Athena
Common Security Patterns to Look For
High-Risk Findings
Old Access Keys (90+ days)
Old Access Keys (90+ days)
Query:Risk: Long-lived credentials increase the window for compromise.Remediation: Implement automated key rotation or migrate to temporary credentials (IAM roles).
Users with Console Access but No MFA
Users with Console Access but No MFA
Query:Risk: Credentials can be compromised without MFA protection.Remediation: Enforce MFA via IAM policies or SCPs.
Never-Used Access Keys
Never-Used Access Keys
Query:Risk: Unused keys may have been created for testing and forgotten.Remediation: Delete unused keys after 30 days.
Inactive Users (Password Never Used)
Inactive Users (Password Never Used)
Query:Risk: Dormant accounts that may not be monitored.Remediation: Review and delete or disable unused accounts.
Compliance Checks
| Control | Query |
|---|---|
| AWS CIS 1.4: Ensure access keys are rotated every 90 days | Filter created_date older than 90 days |
| AWS CIS 1.2: Ensure MFA is enabled for all IAM users with console password | Filter password_status = 'Configurada' AND mfa_status = 'None' |
| NIST 800-53 IA-5: Credential management | Identify keys not used in 45 days |
Tracking Remediation with CloudTrail Events
Use the CloudTrail events CSV to track key deletions and user removals:Data Retention and Security
Next Steps
Running an Audit
Run another audit to track progress
Setup Guide
Configure audit roles in more accounts
