0%
AWS Solutions Architect Associate (SAA-C03) Exam Prep: Secure, Resilient, High-Performing and Cost-Optimized Architectures
Domain 2: Design Resilient Architectures
Domain 3: Design High-Performing Architectures
Domain 4: Design Cost-Optimized Architectures
Final Review and Mock Exams
Detecting Threats and Auditing Changes
The secure architectures domain does not end at prevention. A good design also records what happened, detects when something goes wrong and supports investigation and audit. AWS has a family of services for this, and exam questions test whether you can match each requirement to the right one. This lesson starts with the record of every action, AWS CloudTrail.
What CloudTrail records
CloudTrail records API activity in an AWS account: calls made through the console, the CLI, SDKs and AWS services acting on your behalf. Each event includes who made the call, the identity type and the role session if a role was used, the time, the source IP address, the user agent, the request parameters and the response elements. Questions that ask who deleted a resource, who changed a security group or which role made an API call are answered with CloudTrail.
CloudTrail separates events into three kinds. Management events are control plane operations, such as creating an instance, changing an IAM policy or deleting a bucket; they are recorded by default. Data events are high volume data plane operations, such as S3 GetObject and PutObject, Lambda Invoke and DynamoDB item operations; they are not recorded by default, because of their volume, and incur charges when enabled. Network activity events record API calls made through VPC endpoints. Insights events, also optional, identify unusual patterns in API call rates or error rates, such as a sudden burst of delete calls, compared with a baseline for the account.
Event history versus trails
Without any setup, every account has CloudTrail event history: a searchable view of the last 90 days of management events in each Region, at no charge. Event history cannot be extended and does not include data events. For anything longer or more complete, you create a trail. A trail delivers events to an S3 bucket as log files, typically within a few minutes of the API call, and can also send them to CloudWatch Logs and publish notifications through SNS. A trail can apply to all Regions, which is the recommended setting so that activity in an unused Region is not missed, and it can include global service events such as IAM.
When a question says an auditor needs a year or more of API history, the answer is a trail to S3, with lifecycle rules moving older logs to cheaper storage classes. Event history alone does not meet any requirement longer than 90 days.
Organization trails
An organization trail is created in the management account, or in a delegated administrator account, and records events for every account in the organization, including accounts added later. Member accounts can see the trail but cannot change or delete it. The log files go to a bucket that is usually in the dedicated log archive account, with a bucket policy that allows CloudTrail to write and allows almost nobody else to change or delete anything. Control Tower creates exactly this setup.
This design answers several exam requirements at once: one place to see activity across all accounts, protection of logs from administrators of the accounts being logged, and automatic coverage of new accounts.
Protecting the integrity of logs
An attacker who gains access often tries to hide their tracks by deleting or editing logs. Several features defend against this. Log file integrity validation makes CloudTrail deliver digest files every hour that contain hashes of the log files and are signed by CloudTrail; validating them later proves whether any log file was modified, deleted or added after delivery. Storing logs in a separate account limits who can touch them. S3 Object Lock and versioning on the log bucket prevent deletion. SCPs can deny cloudtrail:StopLogging, DeleteTrail and UpdateTrail to everyone in member accounts. Encrypting log files with SSE-KMS adds a requirement for decrypt permission on the key to read them.
When a question asks how to prove that CloudTrail logs have not been tampered with, the answer is log file integrity validation. When it asks how to prevent deletion, the answer is Object Lock, a separate account and SCPs.
Searching and analysing CloudTrail data
Log files in S3 can be queried with Amazon Athena, which reads the JSON directly and is the usual answer for ad hoc analysis of large volumes of past events at low cost. CloudTrail Lake is a managed alternative: it stores events in event data stores, with retention of up to several years, and lets you run SQL queries directly, without managing buckets, partitions or tables. It can also ingest events from sources outside AWS. Sending a trail to CloudWatch Logs enables near real time searching and metric filters, covered later in this lesson.
What CloudTrail does not do
CloudTrail records API calls; it does not record what happens inside an instance, such as an operating system login or a file being read on disk, and it does not record network traffic, which is the job of VPC Flow Logs. It also does not record the configuration state of resources over time in a convenient form; that is AWS Config. Distinguishing these three records, API calls, network flows and configuration history, solves many questions in this domain.
Trail settings that matter
A trail has a handful of settings that questions test. A multi-Region trail records events from every Region, including Regions enabled later, so activity in a Region the company does not use still shows up. Global service events, such as IAM and STS calls, are recorded once in the trail's home Region, so a set of single Region trails can miss or duplicate them. Log files can be encrypted with SSE-KMS using a key whose policy allows CloudTrail to encrypt and only the security team to decrypt. An SNS notification for each delivered log file lets downstream tools pick up new files as they arrive.
Advanced event selectors control which data events are recorded and reduce cost. Instead of recording every S3 object operation in the account, a selector can record only write operations on buckets whose names start with a given prefix, or only Lambda invocations of particular functions. When a question asks how to record object access for one sensitive bucket without paying for data events everywhere, a selector scoped to that bucket is the answer.
Delivery timing and near real time needs
CloudTrail usually delivers log files to S3 within about five minutes of an API call, which is fine for audit and investigation but not for immediate reaction. For near real time reaction, use EventBridge, which receives management events as they happen, or CloudWatch Logs with metric filters. A question that asks for a response within seconds of a specific call, such as someone disabling encryption on a bucket, should not rely on polling the S3 log files.
Who can read the logs
CloudTrail logs are sensitive in their own right, because they reveal resource names, IP addresses and the shape of an environment. Read access to the log bucket should be limited to the security and audit roles, and reading should itself be logged. Auditors from outside the company can be given a role in the log archive account with read only access to the bucket, rather than access to the workload accounts. When the logs are encrypted with a customer managed key, a reader also needs kms:Decrypt on that key, which gives a second, independent control over who sees the history.
Common mistakes in exam options
Some options look reasonable but fail on a detail. A trail in only one Region misses activity elsewhere. A trail per account managed by each account's administrators can be stopped by those administrators. Relying on event history fails any retention requirement over 90 days. Turning on data events for every bucket in a large account meets the requirement but is rarely the most cost effective choice. Expect the best answer to be the organization trail with a scoped selector and protected storage.
Event history keeps 90 days of management events in each Region for free. Anything longer, any data events or a central view across accounts needs a trail, usually an organization trail to a log archive bucket.