Volume 3 · Chapter 6 — Identity, Security and Compliance

Threat Detection, Logging, and Governance

Goutham Mayaluri 10 min read AWSCloudSecurityComplianceLogging

6.1 Introduction

Prevention is only half of security; you also need to see what’s happening, detect threats, and enforce rules across the organization. AWS provides a layered set of services for this: CloudTrail for an audit trail of every action, Config for tracking configuration and compliance, GuardDuty for threat detection, Security Hub for centralizing findings, and Organizations with service control policies for governance. WAF and Shield protect at the application edge. This chapter ties these together into the detective and governance controls a regulated bank must have alongside its preventive ones.

6.2 CloudTrail: The Audit Trail

CloudTrail records every API call made in the account - who did what, to which resource, when, and from where - producing a complete audit trail of all activity. This is foundational for security and compliance: it’s how you investigate an incident (what did this compromised identity do?), demonstrate compliance (prove who accessed sensitive data), and detect suspicious behaviour. A bank sends CloudTrail logs to a secure, centralized, tamper-resistant location - often a dedicated logging account - so the record is preserved and can’t be altered by someone covering their tracks. Without CloudTrail you’re blind to what happened; with it, every action is accountable.

6.3 Config, GuardDuty, and Security Hub

Three services build detection on top of that visibility. AWS Config tracks the configuration of resources over time and evaluates them against rules, so you can see how a resource was configured at any point and be alerted when something drifts out of compliance - for example, a bucket becoming public or encryption being disabled. GuardDuty is a threat-detection service that continuously analyzes activity (API calls, network logs) using threat intelligence and machine learning to spot suspicious behaviour - unusual API usage, compromised credentials, communication with known-malicious hosts - and raises findings. Security Hub aggregates findings from GuardDuty, Config, and other tools into a single view with compliance-standard checks, so security teams have one place to see the account’s posture and prioritize issues rather than juggling many separate consoles.

flowchart TB
  CT[CloudTrail - every API call] --> Hub[Security Hub - central findings + posture]
  Cfg[Config - resource config & compliance] --> Hub
  GD[GuardDuty - threat detection] --> Hub
  Hub --> Team[Security team / automated response]
  SCP[Organizations SCPs - preventive guardrails] -. enforce .-> Accounts[(All accounts)]

6.4 Edge Protection: WAF and Shield

At the application edge, two services defend against external attacks. AWS WAF (Web Application Firewall) filters incoming web requests against rules, blocking common attacks like SQL injection and cross-site scripting, abusive bots, and request patterns you define - typically attached to CloudFront or the Application Load Balancer so malicious requests are stopped before reaching the application. AWS Shield provides DDoS protection, defending against volumetric attacks that try to overwhelm the service, with a standard level always on and an advanced tier for higher-risk targets. For a bank’s public endpoints, WAF and Shield are the front-line filters that absorb and block attacks at the edge, complementing the internal least-privilege and encryption controls.

6.5 Governance with Organizations and SCPs

At enterprise scale, AWS Organizations groups many accounts under central governance, and service control policies (SCPs) enforce guardrails across them. As covered earlier, an SCP’s deny overrides any allow beneath it, so SCPs impose non-negotiable, org-wide limits: deny disabling encryption, deny creating public buckets, restrict resource creation to approved Regions for data residency, deny use of unapproved services. Combined with a multi-account structure - separating production from non-production, isolating the security and logging accounts - this gives strong blast-radius isolation and centralized control. The governance model is that teams manage their own resources within accounts, while Organizations and SCPs impose the hard boundaries the enterprise and its regulators require.

6.6 Banking Production Scenario

A bank runs a multi-account organization with a dedicated security account and a tamper-resistant logging account. CloudTrail from every account flows into the logging account, giving an immutable audit trail of all activity. Config continuously checks resources against compliance rules and flags any drift, GuardDuty watches for threats across accounts, and Security Hub centralizes all findings for the security team. WAF on CloudFront filters malicious web requests at the edge and Shield absorbs DDoS attempts. Organization SCPs deny disabling encryption, deny public buckets, and confine data to Canadian Regions - unbreakable from below. Together these detective and governance controls sit alongside the preventive IAM and encryption controls to give the layered security posture a regulated bank must demonstrate.

6.7 Troubleshooting: Gaps in Detection and Governance

Security-posture gaps show up in predictable ways. If an incident can’t be investigated, CloudTrail may not have been enabled everywhere or its logs weren’t centralized and protected - the fix is org-wide CloudTrail into a secure logging account. If non-compliant resources appear (public buckets, unencrypted stores) despite policy, either Config rules aren’t catching them or - better - the preventive SCP guardrail is missing, since detection alone doesn’t stop the action; the fix is to add the preventive SCP so it’s blocked outright, not just flagged. Alert fatigue from scattered findings is solved by centralizing in Security Hub and prioritizing. Edge attacks reaching the application mean WAF rules or Shield coverage need attention. The principle is defense in depth with both prevention (IAM, encryption, SCPs) and detection (CloudTrail, Config, GuardDuty, Security Hub) - if something slipped through, identify which layer was missing and add it.

Interview Question

How do you build a layered security and governance posture on AWS beyond just IAM and encryption?

Beyond the preventive controls of IAM and encryption, a complete posture needs visibility, threat detection, and governance, layered as defense in depth, because prevention can fail and you must also detect and contain. The foundation of visibility is CloudTrail, which records every API call - who did what, to which resource, when, and from where - giving a complete audit trail. This is essential for investigating incidents, demonstrating compliance, and detecting suspicious activity, and I send it to a centralized, tamper-resistant logging account so the record can’t be altered by someone covering their tracks. On top of that visibility I add detection. AWS Config tracks resource configurations over time and evaluates them against rules, alerting when something drifts out of compliance - a bucket going public, encryption being disabled - and showing how a resource was configured at any point. GuardDuty continuously analyzes activity and network data with threat intelligence and machine learning to spot suspicious behaviour like compromised credentials, unusual API usage, or communication with malicious hosts, raising findings. Security Hub aggregates findings from GuardDuty, Config, and other sources into a single view with compliance-standard checks, so the security team has one prioritized place to see the account’s posture rather than juggling many consoles. At the application edge I add WAF to filter malicious web requests - injection, cross-site scripting, bad bots - typically on CloudFront or the load balancer so attacks are blocked before reaching the app, and Shield for DDoS protection against volumetric attacks. For governance across the enterprise, I use AWS Organizations with service control policies to enforce non-negotiable guardrails across all accounts - denying disabling encryption, denying public buckets, restricting resources to approved Regions for data residency - and because an SCP’s deny overrides any allow beneath it, these limits are unbreakable from below; combined with a multi-account structure that separates production from non-production and isolates security and logging accounts, this gives blast-radius isolation and central control. The key insight is that these form layers with distinct roles: SCPs and IAM and encryption prevent, CloudTrail provides the audit trail, Config and GuardDuty and Security Hub detect and centralize, and WAF and Shield protect the edge - and crucially, detection is not a substitute for prevention. If Config merely flags a public bucket, that’s worse than an SCP that blocks it from being created; so I use preventive guardrails where possible and detective controls to catch what slips through. That combination of prevention, visibility, detection, and central governance is the layered posture a regulated bank must demonstrate.

Interview Question

Why is CloudTrail so important, and how does a multi-account structure with SCPs improve security?

CloudTrail is important because it is the audit trail of everything that happens in an AWS environment - it records every API call, capturing who performed the action, what action it was, which resource it affected, when, and from where. That complete record is foundational for three things a bank absolutely needs. First, incident investigation: if an identity is compromised or something goes wrong, CloudTrail is how you reconstruct exactly what was done, which is impossible without it. Second, compliance: regulators require you to demonstrate who accessed sensitive data and what changes were made, and CloudTrail provides that evidence. Third, detection: unusual patterns in the trail can reveal suspicious activity, and services like GuardDuty analyze it to spot threats. Because the trail’s integrity is so important, a bank sends CloudTrail logs to a centralized, tamper-resistant logging account so no one - including an attacker who gained access - can alter or delete the record to cover their tracks. Without CloudTrail you’re blind to activity; with it, every action is accountable and auditable. A multi-account structure with service control policies improves security in complementary ways. Using separate accounts - production versus non-production, a dedicated security account, an isolated logging account, separate accounts per workload or business unit - creates strong blast-radius isolation: a compromise or mistake in one account is contained and doesn’t automatically reach others, and sensitive functions like logging and security tooling are separated from workloads. Service control policies, applied through AWS Organizations across those accounts, enforce non-negotiable guardrails: they can deny disabling encryption, deny creating public buckets, restrict resource creation to approved Regions for data residency, and forbid unapproved services. The power comes from the evaluation rule that an explicit deny always wins, so an SCP’s deny overrides any allow granted within an account - the limits hold no matter what an account’s own administrators try to permit, making them true organization-wide boundaries that cannot be exceeded from below. Together, the multi-account structure gives isolation and separation of duties, while SCPs give centrally-enforced, unbreakable guardrails, and CloudTrail gives the complete, protected audit trail across all of it. This combination - contain, constrain, and record - is exactly the governance a regulated financial institution must have, and it’s why these aren’t optional extras but core parts of the security architecture.

Chapter Revision Notes

  • CloudTrail records every API call - the audit trail for investigation, compliance, and detection; centralize it in a tamper-resistant logging account.
  • Config tracks configuration and compliance drift; GuardDuty detects threats; Security Hub centralizes findings and posture.
  • WAF filters malicious web requests at the edge (on CloudFront/ALB); Shield provides DDoS protection.
  • Organizations + SCPs enforce unbreakable org-wide guardrails (deny disabling encryption, public buckets, non-approved Regions).
  • Defense in depth needs both prevention (IAM, encryption, SCPs) and detection (CloudTrail, Config, GuardDuty, Security Hub); prevention beats detection where possible.