Sub topic 12
Centralizing logs and security tooling
This chapter assumes you have read the chapters on trusted access and delegated administrators, and on creating accounts. You should know what a service principal is, how an SCP is attached to an OU, and how to read an S3 bucket policy.
Why centralize
In a multi-account setup, every account produces its own audit trail and its own security findings. If each team keeps these in its own account, three problems follow:
- An attacker who compromises a workload account can delete the evidence stored there.
- Security staff must sign in to dozens of accounts to answer one question.
- New accounts start with no logging or detection until someone configures them.
The standard fix is to move two functions out of workload accounts into dedicated accounts. Each function gets its own account, because the people and permissions involved differ.
| Account | Purpose | Who has access |
|---|---|---|
| Log archive | Stores immutable copies of CloudTrail, Config and flow logs in S3 | Very few people, mostly read-only |
| Security tooling (audit) | Runs GuardDuty, Security Hub, Inspector, Macie and similar services as delegated administrator | Security engineers and responders |
Do not use the management account for either job. It is exempt from SCPs, so you want as little running in it as possible.
Audit logs with an organization trail
An organization trail is a CloudTrail trail created in the management account (or a CloudTrail delegated administrator). It logs events from every member account, including accounts created later. Member accounts can see the trail but cannot change or stop it.
First, enable trusted access for CloudTrail, then create the trail. The bucket lives in the log archive account.
aws organizations enable-aws-service-access \
--service-principal cloudtrail.amazonaws.com
aws cloudtrail create-trail \
--name org-trail \
--s3-bucket-name example-org-logs \
--is-organization-trail \
--is-multi-region-trail \
--enable-log-file-validation
aws cloudtrail start-logging --name org-trailcreate-trail fails unless the bucket policy already allows CloudTrail to write to it. For an organization trail, the policy must allow writes under both the management account ID prefix and the organization ID prefix. Apply this in the log archive account:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailAclCheck",
"Effect": "Allow",
"Principal": { "Service": "cloudtrail.amazonaws.com" },
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::example-org-logs",
"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:cloudtrail:us-east-1:111111111111:trail/org-trail"
}
}
},
{
"Sid": "AWSCloudTrailWrite",
"Effect": "Allow",
"Principal": { "Service": "cloudtrail.amazonaws.com" },
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::example-org-logs/AWSLogs/111111111111/*",
"arn:aws:s3:::example-org-logs/AWSLogs/o-exampleorgid/*"
],
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"aws:SourceArn": "arn:aws:cloudtrail:us-east-1:111111111111:trail/org-trail"
}
}
}
]
}Here 111111111111 is the management account and o-exampleorgid is your organization ID. Replace both.
Harden the bucket as well:
- Turn on S3 Object Lock in compliance or governance mode, with a retention period that matches your audit requirements.
- Enable versioning and block all public access.
- Encrypt with a KMS key whose policy allows CloudTrail to encrypt and your auditors to decrypt.
- Keep log file validation on. It produces signed digest files that let you prove logs were not altered.
Configuration history with AWS Config
CloudTrail records API calls. AWS Config records resource state over time and evaluates it against rules. Config runs per account and per Region, so centralization means two steps:
- Turn on a configuration recorder in every account and Region you use. Do this with a baseline in your IaC pipeline, or through Control Tower.
- Create an aggregator in the security tooling account. An organization aggregator uses trusted access (
config.amazonaws.com) to pull data from all accounts without per-account authorization.
An aggregator gives you read access to compliance data. It does not turn the recorders on. Accounts without a recorder simply do not appear in the data.
Security services with delegated administrators
Most AWS security services follow the same pattern from the previous chapter. The management account designates the security tooling account as delegated administrator. That account then enables the service for the organization and configures automatic enrollment for new accounts.
| Service | What the delegated admin can do |
|---|---|
| GuardDuty | View findings from all members and auto-enable for new accounts |
| Security Hub | Aggregate findings and apply standards across accounts |
| Inspector | Manage vulnerability scanning for EC2, ECR and Lambda |
| Macie | Manage sensitive data discovery in S3 |
| IAM Access Analyzer | Create an organization-wide analyzer to find external and cross-account access |
GuardDuty shows the typical sequence. Run the first command in the management account and the others in the security tooling account. Each step is per Region.
aws guardduty enable-organization-admin-account \
--region eu-west-1 \
--admin-account-id 222222222222
DETECTOR_ID=$(aws guardduty list-detectors \
--region eu-west-1 \
--query 'DetectorIds[0]' --output text)
aws guardduty update-organization-configuration \
--region eu-west-1 \
--detector-id "$DETECTOR_ID" \
--auto-enable-organization-members ALLALL enrolls existing and future member accounts. NEW enrolls only accounts created afterward.
Security Hub works the same way with aws securityhub enable-organization-admin-account --admin-account-id 222222222222. It also offers cross-Region aggregation, so you can read findings from every Region in one place.
Protecting the pipeline with an SCP
A trail or detector is only useful while it stays on. Use an SCP on the root or on the Workloads OU to stop member-account administrators from turning these services off:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyDisablingSecurityTooling",
"Effect": "Deny",
"Action": [
"cloudtrail:StopLogging",
"cloudtrail:DeleteTrail",
"cloudtrail:UpdateTrail",
"config:StopConfigurationRecorder",
"config:DeleteConfigurationRecorder",
"guardduty:DeleteDetector",
"guardduty:DisassociateFromMasterAccount",
"guardduty:UpdateDetector"
],
"Resource": "*"
}
]
}Application and network logs
Other logs follow the same idea: send them to a central account, and keep the source account unable to delete them.
- VPC Flow Logs: publish directly to an S3 bucket in the log archive account. The bucket policy must allow
delivery.logs.amazonaws.com. - CloudWatch Logs: use cross-account subscription filters to stream to a Kinesis Data Firehose or a destination in the log archive account. Alternatively, use CloudWatch Observability Access Manager to query logs in other accounts without copying them.
- S3 server access and ALB logs: write to a central bucket, and be careful with Region restrictions on the target bucket.
Common errors
InsufficientS3BucketPolicyExceptiononcreate-trail: the bucket policy is missing the organization ID path, or it names the wrong trail ARN.- KMS access denied when reading logs: the key policy lists CloudTrail but not the security team's role in the log archive account.
- Findings from new accounts do not appear: auto-enable was set in one Region only. Configure each Region you use, and use an SCP to block Regions you do not.
- Config shows few accounts: the aggregator exists but recorders were never deployed.
- Delegated admin was set in the wrong Region: GuardDuty and Security Hub designate administrators per Region.
Exercise
A new account is created in the Workloads OU. You have an organization trail, GuardDuty auto-enable set to NEW in eu-west-1, and no AWS Config recorder baseline. What will you see for that account in the first hour, and what is missing?
Show answer
CloudTrail events from the account arrive in the log archive bucket, because an organization trail covers new accounts automatically. GuardDuty is enabled in eu-west-1 and its findings reach the delegated administrator. Nothing appears in the Config aggregator, because no recorder exists in the account. You need to deploy a Config recorder through an IaC baseline or Control Tower. GuardDuty is also not enabled in any other Region you use unless you configure auto-enable there too.