Schedule icon
Script icon
Script icon
Docker icon
OutputValues icon
If icon
SlackIncomingWebhook icon
Fail icon
Log icon

Detect CloudTrail Management-Event Logging Gaps

Audit AWS CloudTrail logging, management-event selectors, multi-Region coverage, and log-file validation with a PASS/BLOCK report.

Categories
CloudInfrastructure

Check one named CloudTrail trail against a strict management-event coverage policy. The flow reads AWS state. It does not change a trail or its destination bucket.

How it works

  1. validate_inputs rejects invalid Region, trail name, and freshness settings.
  2. read_trail calls DescribeTrails, GetTrailStatus, and GetEventSelectors for the exact home-Region trail.
  3. check_coverage requires active logging, a multi-Region trail, global service events, log file validation, an S3 destination, and full read/write management-event selectors.
  4. publish_report exposes the saved JSON report. coverage_gate posts to Slack and fails on BLOCK.

Prerequisites

  • Run in the trail's home account and Region. Run in the organization management or delegated account for an organization trail; shadow trails are excluded from the search.
  • IAM read permission for cloudtrail:DescribeTrails, cloudtrail:GetTrailStatus, and cloudtrail:GetEventSelectors.
  • Kestra Python and Node Script plugins with a Docker task runner, Docker image access, and Python package installation access.

Secrets

  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY: IAM credentials with read-only CloudTrail permissions.
  • SLACK_WEBHOOK_URL: webhook for blocked checks.

Quick start

  1. Set the secrets. Set region to the trail's HomeRegion and trail_name to its exact name.
  2. Run manually and open outputs.publish_report.values.report_uri.
  3. Test a trail with logging disabled or log file validation disabled. Verify the BLOCK path and Slack alert.
  4. Keep max_delivery_age_hours at 0 if the account has long periods with no events. Enable it only for accounts with regular log delivery.
  5. Enable the disabled schedule after checking the PASS and BLOCK paths.

Output and limits

  • PASS proves the returned trail configuration meets this policy at scan time. It does not prove that logs arrived, are unmodified, or cover data events.
  • The optional delivery threshold checks LatestDeliveryTime only. Low-activity accounts can fail this check even when CloudTrail works.
  • Historical LatestDeliveryError and LatestDigestDeliveryError are recorded as notes. AWS does not provide a reliable current-failure timestamp in those fields.
  • A missing trail, incomplete API response, or selector that only covers read or write events cannot produce PASS.
  • A failure to call AWS fails the execution before a PASS result. Configure Kestra execution-failure alerts separately.
  • To verify actual log integrity, run AWS CLI cloudtrail validate-logs for a selected time range.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.