Lesson 2 of 5 Compliance, Auditing and AI Safeguards

Auditing ML Systems with CloudTrail, Invocation Logs and AWS Config

This lesson explains how regulated organisations show who did what to ML systems, what models were asked and answered, and whether configurations meet policy, using AWS CloudTrail and AWS Config.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish CloudTrail management and data events.
  • Use model invocation logging and other logs.
  • Evaluate configurations with AWS Config rules.

AWS CloudTrail

CloudTrail records API calls as events: who (principal), what (action), when, from where and with what result. Management events cover control-plane calls such as creating endpoints, training jobs, knowledge bases, guardrails or changing model approval status. Data events, which must be enabled explicitly, cover high-volume data-plane operations such as S3 object reads and writes and, for supported services, invocations. A trail delivers events to S3 (with log file integrity validation) and optionally to CloudWatch Logs; an organisation trail covers all accounts.

Sort into groups

Which log?

Exam skills 4.3.4

Choose where to find each piece of audit evidence.

Log in to try this activity Interactive activities are free with an account.

Model invocation logging and other logs

Bedrock model invocation logging records the full request and response of model invocations, including prompts, outputs and metadata, to CloudWatch Logs or S3, which CloudTrail does not capture. Because these logs may contain sensitive data, encrypt them with KMS, restrict access, and use CloudWatch Logs data protection policies to mask sensitive values. SageMaker AI data capture records endpoint requests and responses. Container and job logs go to CloudWatch Logs with retention policies matching regulatory requirements.

The following diagram matches each regulatory requirement for an ML platform to the evidence that proves it.

The evidence for each regulatory requirement. An organisation CloudTrail trail with log file validation, delivered to an Object Lock bucket, shows who changed each model; an AWS Config conformance pack shows that endpoints stayed encrypted; and Bedrock invocation logging to an encrypted bucket with a seven-year lifecycle retains the AI responses.
The scenario is illustrative.

AWS Config

AWS Config records resource configurations over time and evaluates them against rules. Managed rules exist for SageMaker AI, such as notebook instances without direct internet access, endpoint configurations with KMS keys and notebook instances with KMS keys, and custom rules can check other settings. Conformance packs group rules for a framework, and remediation actions can fix non-compliant resources. The following table summarises the services.

QuestionService
Who created, changed or deleted an ML resource?CloudTrail management events
Who read the training data objects?CloudTrail S3 data events
What did the model receive and return?Bedrock invocation logging, SageMaker data capture
Are resources configured according to policy?AWS Config rules and conformance packs
How is each model documented and traced?Model cards and lineage (next lesson)
True or false

AWS Config

Exam skills 4.3.4

Check what AWS Config does for ML compliance.

Log in to try this activity Interactive activities are free with an account.
Worked example

Preparing for an audit

A bank's regulator requires evidence that model endpoints are encrypted, that every model change is traceable to a person, and that customer-facing AI responses are retained for 7 years.

  • An organisation CloudTrail trail with log file validation, delivered to an Object Lock bucket in a log archive account.
  • AWS Config conformance pack with SageMaker AI encryption and network rules, with compliance history.
  • Bedrock invocation logging to an encrypted S3 bucket with a 7-year lifecycle and restricted access.

CloudTrail alone would not show the AI responses, and invocation logging alone would not show who changed the configuration; the audit needs both, plus Config for configuration compliance.

Check yourself

What must be enabled to record S3 object access in CloudTrail?

Show answer

Data events.

Exam Tips

Remember for the exam

  • Who did what: CloudTrail; S3 object access needs data events.
  • Prompts and responses: Bedrock model invocation logging.
  • Configuration compliance: AWS Config rules and conformance packs.
  • Encrypt and restrict access to invocation logs; mask sensitive data.
  • Organization trails cover all accounts.