View a markdown version of this page

SEC04-BP01 Configure service and application logging - AWS Well-Architected Framework

SEC04-BP01 Configure service and application logging

Capture access logs, network flow records, and configuration change events from every component in your workload. This evidence helps you detect threats and reconstruct incidents.

Desired outcome:

  • Your workload emits logs from every component that supports them, across the infrastructure and application layers.

  • You collect security-relevant events such as access, permission changes, network flows, and configuration changes in a consistent, queryable format.

  • Your logs are centralized, retained according to defined policies, and protected by access controls that prevent unauthorized reading or modification.

  • You mask or remove sensitive data before it reaches log storage.

  • You can query and correlate logs quickly enough to support active incident response.

Common anti-patterns:

  • Teams enable logging on some components but leave others silent, which creates blind spots during investigations.

  • Logs are stored in fragmented formats and locations, which makes correlation across components slow or impossible.

  • Organizations set no retention policy, so investigators lose historical data or storage costs grow without bound.

  • Log stores lack access controls, so unauthorized parties can read or tamper with security evidence.

  • Sensitive data such as credentials or personal information lands in logs unmasked.

Benefits of establishing this best practice:

  • Detection and investigation are faster, because relevant events are captured and searchable in one place.

  • Incident response is stronger, because responders can reconstruct a timeline from consistent logs.

  • Risk of data exposure drops, because sensitive values are removed before storage.

  • Compliance is more straightforward to demonstrate, because retention and access controls meet audit requirements.

  • Evidence stays reliable, because access controls protect logs from tampering.

Level of risk exposed if this best practice is not established: High

Implementation guidance

Workloads produce security-relevant signals in multiple places. For example, the control plane records API calls, the network layer records traffic flows, and the application layer records authentication and authorization events. Each layer answers a different investigative question, so unlogged layers create gaps at investigation time. Identify the components that matter for your threat model, and confirm each one produces logs.

Treat log stores as high-value assets. Unauthorized read access reveals how you monitor, while write or delete access lets an attacker erase evidence. Restrict read and write access to the smallest set of systems and people. Store logs in accounts separate from the ones that generate them, so an affected workload cannot destroy its own audit trail. Centralize logs into a single destination, which is easier to lock down and search than many scattered ones.

Attackers can also disable logging entirely. Someone with the right permissions can stop a trail or delete a GuardDuty detector. Treat a change to your logging or detection configuration as a security event. Set detection at the organization level with GuardDuty organization management. Enable log file integrity validation on your trail. Alert on the API calls that disable any of these methods.

Applications often write request bodies, headers, or error payloads that contain credentials, tokens, or personal information. Once that data lands in a log store, it inherits the exposure of everyone who can read the store. Identify the sensitive fields your components emit and mask or drop them before they reach log storage. Scrubbing logs after the fact is unreliable.

Keep logs long enough to satisfy investigations and compliance obligations, but not so long that storage cost outweighs their value. Different log types justify different retention periods, and some regulations require a minimum. Set retention deliberately for each log type.

AWS CloudTrail records API activity, AWS Config records resource configuration changes, and Amazon VPC Flow Logs record network traffic. Amazon CloudWatch consolidates operational, security, and compliance logs from across accounts and Regions with cross-account cross-Region log centralization. Its transformation pipelines can normalize security data to OCSF. For analysis, CloudWatch Logs Insights queries data in log groups and the unified store; Amazon Athena and Amazon OpenSearch Service query data in Amazon S3. To link events across sources, AWS Security Hub CSPM correlates and enriches findings from GuardDuty, Inspector, and Security Hub CSPM into prioritized exposure findings with attack path context. A third-party SIEM can serve the same role.

Implementation steps

  1. Enable foundational logging: Turn on the account-wide sources that apply to almost every workload. CloudTrail's event history holds only 90 days of management events, so create an organization trail that covers every account and Region and delivers a durable record for investigations and audit. Enable AWS Config for configuration changes and Amazon VPC Flow Logs for network traffic.

  2. Enable service-specific logging: For each AWS service in your workload, configure its native logs. Common sources include Amazon GuardDuty finding export, AWS WAF web ACL traffic logging, AWS Network Firewall logging, Elastic Load Balancing access logs, Amazon RouteĀ 53 Resolver query logs, Amazon RDS logs, Amazon EKS control plane logs, and the Amazon CloudWatch agent for Amazon EC2 instances and on-premises servers.

  3. Instrument custom applications: Add logging to your own application code to capture security-relevant events such as user access, permission changes, and modifications to key components. Emit these events in a consistent, structured format so they can be parsed and correlated with infrastructure logs.

  4. Mask sensitive data before ingestion: Identify the fields your components emit that contain credentials, tokens, or personal information. Remove or mask those fields before events are written, and apply CloudWatch Logs data protection policies to detect and mask sensitive data that still reaches log groups.

  5. Centralize logs: Aggregate logs from all workload components into a central destination. Use cross-account cross-Region log centralization to replicate logs into a single account, and telemetry enablement rules to turn logging on automatically as resources appear. Normalize security data to OCSF in the same pipeline so formats match across sources. Centralization gives you unified visibility and a single boundary to secure.

  6. Restrict access to logs: Apply access controls so that only authorized systems and individuals can read or modify logs. Keep log storage separate from the accounts that generate the logs to protect the audit trail from a workload under unauthorized control.

  7. Set retention policies: Define retention per log type based on security, audit, and compliance needs, balanced against storage cost. Confirm each retention setting meets any regulatory floor that applies to that data.

  8. Enable querying and correlation: Select query mechanisms that fit where your logs live. Use CloudWatch Logs Insights for CloudWatch log groups and the unified data store, and Amazon Athena or Amazon OpenSearch Service for data in Amazon S3. For cross-source investigation, AWS Security Hub CSPM correlates findings from multiple AWS security services and presents them with exposure context and attack path visualization, or use a SIEM for the same purpose.

  9. Monitor and alert on anomalies: Review logs for patterns that indicate security threats or unauthorized activity, and route findings to the teams that own the affected components. Establish this monitoring as an ongoing process rather than a one-time setup.

Resources

Related best practices:

Related documents:

Related examples: