Skip to main content
Cloud Logging (CloudTrail, Activity Logs) & CSPM Basics
Lesson 4 of 11

Cloud Logging (CloudTrail, Activity Logs) & CSPM Basics

Learn how cloud control-plane audit logs record API activity across AWS, Azure and GCP, how to inspect CloudTrail JSON for suspicious IAM changes, and how CSPM tools like Prowler detect configuration drift.

Intermediate 24 min Cloud & DevSecOps

Learning objectives

  • Distinguish control-plane audit logs from data-plane and diagnostic logs across major cloud providers
  • Identify key fields in an AWS CloudTrail JSON record to investigate unauthorized API calls
  • Explain how Cloud Security Posture Management (CSPM) tools evaluate cloud accounts against security baselines
  • Configure multi-region, tamper-evident logging and remediate common audit blind spots

Recommended first: Cloud Fundamentals & Shared Responsibility (AWS, Azure, GCP)Cloud IAM: Policies, Roles, Federation & Privilege PathsCloud Networking (VPCs, Security Groups) & Storage Security

#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)
  1. API CallIAM or resource request hits provider endpoint
  2. RecordControl-plane logger captures identity, IP and parameters
  3. DeliverJSON events shipped to central immutable storage or SIEM
  4. 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.
  • eventSource and eventName: the service and exact API action (for example iam.amazonaws.com and CreateAccessKey).
  • userIdentity: who made the call, including type (IAMUser, AssumedRole, Root), arn, and accountId.
  • sourceIPAddress and userAgent: where the call originated and which client SDK or CLI sent it.
  • requestParameters, responseElements, and errorCode: what inputs were sent, what was created, or why the call failed.

Consider this sanitized event recorded in a lab environment:

json
{
  "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) to 0.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:

Running targeted Prowler checks in a lab account
$ 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.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge