Skill 2.2.6

Identify, mask, and limit access to sensitive data (for example, personally identifiable information [PII], protected health information [PHI]) by using AWS services.

Key Concepts

Personally identifiable information (PII) identifies a person, such as names, email addresses, government IDs and payment card numbers. Protected health information (PHI) is health data linked to a person and is regulated by laws such as HIPAA. Other categories include credentials, financial data and confidential business data.

Classification drives handling: sensitive data should be encrypted with controlled keys, accessible to as few principals as possible, kept out of logs and deleted when no longer needed. Tagging resources by classification lets IAM policies and audits act on it.

Applications can mask data in code before logging, displaying or sharing it. Powertools for AWS Lambda includes a data masking utility that can erase fields or encrypt them with KMS so only authorised consumers can decrypt them.

CloudWatch Logs data protection policies detect sensitive data such as email addresses, credentials and card numbers in log events and mask them automatically; only principals with the logs:Unmask permission can view the original values. Amazon SNS message data protection policies can similarly audit, mask or block sensitive data in published messages, although the feature closed to new customers on 30 April 2026, so new applications mask sensitive fields in code before publishing.

Inputs should be validated and sanitised before use to prevent injection attacks: use parameterised queries for SQL, encode output for HTML, and validate request bodies with API Gateway models or your own schema checks. AWS WAF adds protection against common attacks such as SQL injection and cross-site scripting at API Gateway, CloudFront or the load balancer.

Outputs must also be sanitised: error messages returned to clients should not reveal stack traces, internal hostnames or data, and logs should never contain passwords, tokens or full card numbers. Strip sensitive fields before writing logs or sending data to analytics.

In the silo model each tenant gets separate resources, such as its own table, bucket or account, which gives strong isolation at higher cost. In the pool model tenants share resources and every item carries a tenant ID, for example as the DynamoDB partition key prefix or an S3 prefix, which is cheaper but relies on correct access controls.

In pooled designs, isolation should be enforced by AWS rather than only by application code. A common pattern assumes a role with session tags or a scoped-down session policy for the current tenant, so IAM conditions such as dynamodb:LeadingKeys or S3 prefixes using ${aws:PrincipalTag/tenant} restrict access. Relational databases can use row-level security, and per-tenant KMS keys can separate encrypted data.