#Why this matters
In an earlier lesson you saw how IAM roles and policies govern what principals can do in the cloud. When an attacker obtains leaked credentials, they rarely send noisy port scans across your network. Instead, they call the cloud provider's management APIs directly to enumerate roles, create new access keys, or open storage permissions.
Without audit logging, those API calls leave no trace on any virtual machine disk. Cloud audit logs provide the authoritative record of who called which API, from where, and whether the call succeeded, while Cloud Security Posture Management (CSPM) continuously scans account settings so misconfigurations do not linger unnoticed.
#Control-plane vs data-plane logs across clouds
Every major provider separates control-plane events (changes to infrastructure, IAM, and configuration) from data-plane events (reads and writes against stored objects or records). Control-plane logs are usually enabled by default for recent events, whereas long-term retention and data-plane logs require explicit configuration.
| Provider | Control-plane audit log | Data-plane / resource log | Typical default retention |
|---|---|---|---|
| AWS | CloudTrail Management Events | CloudTrail Data Events (S3, Lambda) | 90 days in Event History |
| Azure | Azure Activity Log | Resource Diagnostic Logs | 90 days in Activity Log |
| GCP | Cloud Audit Logs (Admin Activity) | Cloud Audit Logs (Data Access) | 400 days (Admin Activity) |
- API CallIAM or resource request hits provider endpoint
- RecordControl-plane logger captures identity, IP and parameters
- DeliverJSON events shipped to central immutable storage or SIEM
- EvaluateAlerts and CSPM checks flag risky changes or drift
#Reading a CloudTrail event
AWS CloudTrail stores each API call as a structured JSON object. Five fields answer most initial triage questions:
eventTime: UTC timestamp of the request.eventSourceandeventName: the service and exact API action (for exampleiam.amazonaws.comandCreateAccessKey).userIdentity: who made the call, includingtype(IAMUser,AssumedRole,Root),arn, andaccountId.sourceIPAddressanduserAgent: where the call originated and which client SDK or CLI sent it.requestParameters,responseElements, anderrorCode: what inputs were sent, what was created, or why the call failed.
Consider this sanitized event recorded in a lab environment:
{
"eventVersion": "1.08",
"userIdentity": {
"type": "AssumedRole",
"arn": "arn:aws:sts::111122223333:assumed-role/ci-runner/build-42"
},
"eventTime": "2026-10-14T02:18:45Z",
"eventSource": "iam.amazonaws.com",
"eventName": "CreateAccessKey",
"awsRegion": "us-east-1",
"sourceIPAddress": "198.51.100.77",
"userAgent": "aws-cli/2.15.0 Python/3.11.8 Linux/6.6.0",
"requestParameters": {
"userName": "backup-svc"
},
"responseElements": {
"accessKey": {
"accessKeyId": "AKIAEXAMPLE000123456",
"status": "Active"
}
}
}A build role (ci-runner) normally reads artifacts or pushes container images. Seeing it invoke CreateAccessKey for a separate IAM user (backup-svc) from an unexpected external IP (198.51.100.77) using the interactive CLI is a strong persistence indicator.
#Cloud Security Posture Management (CSPM) basics
While audit logs show what happened, CSPM shows how your environment is currently configured. Engineers frequently adjust security groups or storage policies during debugging and forget to revert them. A CSPM scanner queries read-only cloud APIs and grades resources against frameworks such as the CIS Benchmarks.
Common CSPM findings include:
- CloudTrail disabled in unused regions or lacking log file integrity validation.
- Storage buckets allowing public read/list access or missing default encryption.
- Security groups exposing administrative ports (
22,3389) to0.0.0.0/0. - IAM users with active console passwords lacking MFA or carrying unused access keys.
Open-source tools like Prowler run these checks across AWS, Azure, and GCP using read-only permissions:
$ prowler aws --checks cloudtrail_multi_region_enabled iam_user_mfa_enabled_console_access#Defending and common mistakes
- Single-region trails: Attackers intentionally operate in unused regions. Always enable multi-region trails (or organization-level trails) and include global services such as IAM and STS.
- Mutable log storage: Never let workload accounts delete or overwrite log buckets. Enable S3 Object Lock or equivalent immutable retention plus CloudTrail log file validation.
- No alerting on high-risk APIs: Collecting logs without detections is passive storage. Alert on
CreateAccessKey,PutBucketPolicy,StopLogging,DeleteTrail, and root user logins. - Ignoring CSPM drift: Running a scan once before launch is not enough. Schedule daily CSPM checks and route new critical findings to ticket queues.
#Summary
Control-plane logs (CloudTrail, Azure Activity Logs, GCP Admin Activity) record every management API call, making them essential for spotting credential abuse and IAM persistence. Parsing structured JSON fields like eventName, userIdentity, sourceIPAddress, and requestParameters lets defenders quickly isolate suspicious actions such as unauthorized CreateAccessKey calls. Pairing continuous, multi-region, tamper-evident logging with automated CSPM audits closes visibility gaps and catches configuration drift before attackers exploit it.