Masking Sensitive Data in Logs and Messages
This lesson explains how masking hides sensitive values that end up in logs and messages from people and systems that do not need them. Amazon SNS message data protection, named in the exam guide, stopped accepting new customers on 30 April 2026; existing customers can keep using it.
Learning outcomes
After completing this lesson, you will be able to:
- Configure CloudWatch Logs data protection policies.
- Describe the operations of SNS message data protection.
- Identify other masking options, such as Glue sensitive data detection.
CloudWatch Logs data protection
Applications sometimes write sensitive values, such as credit card numbers, email addresses or access keys, into logs, where many people and tools can read them. CloudWatch Logs data protection policies detect these values as log events are ingested and mask them, so they are hidden in the console, in queries and in subscriptions, while the rest of the log remains useful. The following list describes how it works.
- Policies on a log group or the whole account use managed data identifiers (credentials, card numbers, emails, addresses, health data) and custom identifiers.
- Audit reports findings (to CloudWatch Logs, S3 or Firehose); mask de-identifies values as logs are ingested.
- Masked values show as asterisks everywhere; only principals with
logs:Unmasksee originals, e.g.unmask(@message)in Logs Insights.
The following diagram shows an account-level CloudWatch Logs data protection policy and what each reader sees.

CloudWatch Logs data protection
SNS message data protection
An SNS message data protection policy scans messages for sensitive data, such as names, addresses and card numbers, and applies one of three operations. Audit reports what was found, as metrics and logs, without changing the message, which shows how much sensitive data flows through a topic before you act. De-identify masks or redacts the sensitive values before the message is delivered, so subscribers receive a cleaned copy. Deny blocks the message entirely. The following table summarises the operations.
| Operation | Effect |
|---|---|
| Audit | Report sensitive data found |
| De-identify | Mask or redact |
| Deny | Block the message |
Separate rules apply to inbound messages from publishers and outbound deliveries to particular subscribers.
SNS data protection operations
Other masking options
Other services detect or mask sensitive data at different points. Glue sensitive data detection finds PII in data passing through ETL jobs and redacts or hashes it before it is written to the lake. Redshift dynamic data masking masks values in query results according to the user's role, while the stored data is unchanged. Bedrock Guardrails sensitive information filters block or mask PII in the prompts and responses of generative AI applications. The following table summarises the options.
| Tool | Where |
|---|---|
| Glue sensitive data detection | Find and redact PII in ETL jobs |
| Redshift dynamic data masking | Query results |
| Bedrock Guardrails | Sensitive information filters for generative AI |
Where else data is masked
Masking card numbers in application logs
Developers occasionally log full request bodies, which can include card numbers and email addresses. An account-level data protection policy masks them in every log group as they are ingested:
aws logs put-account-policy --policy-name mask-pii --policy-type DATA_PROTECTION_POLICY --scope ALL \
--policy-document '{
"Name": "mask-pii", "Version": "2021-06-01",
"Statement": [
{ "Sid": "audit", "DataIdentifier": [
"arn:aws:dataprotection::aws:data-identifier/CreditCardNumber",
"arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
"Operation": { "Audit": { "FindingsDestination": { "S3": { "Bucket": "acme-dp-findings" } } } } },
{ "Sid": "mask", "DataIdentifier": [
"arn:aws:dataprotection::aws:data-identifier/CreditCardNumber",
"arn:aws:dataprotection::aws:data-identifier/EmailAddress"],
"Operation": { "Deidentify": { "MaskConfig": {} } } }
]
}'Engineers see **** in place of the values. The fraud team, whose role alone holds logs:Unmask, can still investigate with unmask(@message) in Logs Insights. The audit findings show which applications log personal data, so the root cause can be fixed in code.
Who should be able to see original values in a log group with a data protection policy?
Show answer
Only principals granted logs:Unmask, such as the security team.
Exam Tips
Remember for the exam
- To mask credit card numbers in log groups, use a CloudWatch Logs data protection policy.
- To let only the security team see original log values, grant logs:Unmask to them alone.
- To block messages containing PII from being published, use an SNS message data protection deny statement.
- To mask PII for one subscriber only, use an SNS de-identify statement for that subscriber.
- To redact PII during ETL, use Glue sensitive data detection.