Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

2.4.6. Masking, Redaction, and Anonymization

💡 First Principle: Sensitive data must be removed before it becomes part of something you cannot easily edit. A value masked in a source file costs one reprocessing run to fix; a value embedded into a vector index or learned into model weights may require re-ingestion or retraining — and a model can reproduce a memorized training value verbatim.

2.3.4 introduced encryption and detection (Amazon Macie finds sensitive data in S3). Detection tells you where sensitive data is; this subsection is about transforming it. The terms are not interchangeable:

TechniqueWhat happens to the valueReversible?Typical use
MaskingCharacters replaced (****-****-****-1111) or value replaced by its type ([NAME], {EMAIL})No (unless the original is kept elsewhere)Text for FM training or RAG where the entity type still carries meaning
RedactionValue removed or blacked outNoDocuments and transcripts shared beyond the original audience
Hashing / pseudonymizationValue replaced by a consistent surrogate (SHA-256 hash, token)Only with the mapping or by brute force of small value spacesJoining records about the same person without exposing identity
AnonymizationData transformed so individuals cannot reasonably be re-identified, including via combinations of quasi-identifiersNoDatasets released or used broadly
AWS tools and where they fit:
ToolDataCapability
Amazon Comprehend PIIEnglish or Spanish textReal-time detection (up to 100 KB per document) returns entity types and offsets; redaction requires an asynchronous batch job, with MaskMode of MASK (a mask character) or REPLACE_WITH_PII_ENTITY_TYPE
Amazon Comprehend MedicalClinical textDetectPHI finds protected health information (names, ages, dates, IDs, addresses, professions) with confidence scores; AWS recommends additional human review for compliance use
AWS Glue Detect PII transformTabular data in ETL jobsScan every cell or sample columns; actions include redact, partial redact, SHA-256 hash, or enrich with detection results; custom regex patterns with context words
Amazon Transcribe PII redactionAudio transcriptsProduces a redacted transcript, optionally alongside an unredacted one; AWS notes it does not meet HIPAA de-identification requirements on its own
Amazon Bedrock Guardrails sensitive information filtersPrompts and model responses at runtimePer PII type or custom regex: BLOCK, ANONYMIZE (replaced with {NAME}, {EMAIL}), or NONE (detect only)

Choosing the point of control. Use batch tools (Comprehend jobs, Glue, Transcribe) to clean datasets and corpora before training or ingestion; use Guardrails to protect live traffic. Guardrails masking does not rewrite everything: model invocation logs in CloudWatch Logs still contain the original request, so protect those with CloudWatch Logs data protection.

Anonymization is more than PII entity removal. Removing names and IDs can still leave quasi-identifiers — a rare job title plus a small town plus an exact date — that re-identify someone. Generalize them (age bands instead of birth dates, region instead of address) and consider whether free-text fields need summarization or removal. ML-based detectors are probabilistic, so pair them with confidence thresholds, deterministic regex for known formats (account numbers, internal IDs) and sampling review.

⚠️ Exam Trap: Encryption (2.3.4) protects data from people who should not access it; masking protects data from people and models that are allowed to access the dataset. A fine-tuning dataset encrypted with a customer managed KMS key still teaches the model every account number inside it. When the stem says the model or its users must not see personal values, the answer is masking or redaction before training, not stronger encryption.

See how it connects
Alvin Varughese
Written byAlvin Varughese
Founder•20 professional certifications