What is Amazon Macie, and how does it help you find and protect sensitive data in S3?
Answer
Amazon Macie is a data security service that discovers sensitive data such as personal information, financial data and credentials in Amazon S3, and also evaluates your buckets for security risks like public access or missing encryption. It uses machine learning and pattern matching to classify objects, then produces findings you can review or route to automated workflows.
The two things Macie does
Bucket inventory and posture: once enabled, Macie builds an inventory of every S3 bucket in the account and Region and reports whether each one is public, shared with other accounts, encrypted by default, and so on. Changes that weaken security generate policy findings, for example Policy:IAMUser/S3BlockPublicAccessDisabled or Policy:IAMUser/S3BucketPublic.
Sensitive data discovery: Macie reads object contents and generates sensitive data findings such as SensitiveData:S3Object/Personal, SensitiveData:S3Object/Financial, SensitiveData:S3Object/Credentials or SensitiveData:S3Object/Multiple.
How discovery works
Macie offers two modes:
Automated sensitive data discovery: Macie continuously samples objects across your buckets and builds a sensitivity score per bucket. This is the cheap, broad view: "which of my 400 buckets probably contain PII?"
Sensitive data discovery jobs: you target specific buckets, prefixes or object criteria, run once or on a schedule, and Macie inspects every matching object. This is the deep scan for audits.
It identifies data using:
Managed data identifiers: built-in detectors for things like names, addresses, credit card numbers, bank account numbers, AWS secret keys and private keys, with keyword proximity and validation (for example a Luhn check on card numbers).
Custom data identifiers: your own regex plus optional keywords, for example a pattern for an internal customer ID or an Indian PAN format.
Allow lists: text or patterns to ignore, like a sample card number in test data.
Supported formats include text, CSV, JSON, Parquet, Avro, PDF, Microsoft Office files and compressed archives.
Where it fits in a real system
Picture a fintech that stores KYC uploads and loan statements in S3. Regulations such as India's DPDP Act push it to know where personal data lives. Macie lets the security team:
Find a forgotten analytics-exports bucket that contains full customer phone numbers.
Alert when someone disables Block Public Access on a bucket holding KYC documents.
Send findings to EventBridge and Security Hub, then trigger a Lambda that tags the object, moves it to a quarantine bucket or opens a ticket.
Limits and gotchas
S3 only. Macie does not scan RDS, DynamoDB or EBS. For databases you need other tooling or export to S3 first.
Cost is driven by the number of buckets monitored and the volume of data inspected, so blindly running full jobs on petabytes of logs is expensive. Use automated discovery, then targeted jobs.
Macie needs permission to read objects; objects encrypted with a customer managed KMS key whose policy excludes Macie's role will be skipped.
Findings are detective. Prevention still comes from bucket policies, Block Public Access, encryption and least-privilege IAM.
Like GuardDuty, it is Regional and is best enabled organization-wide through a delegated administrator.
How Macie finds sensitive data. Macie inventories buckets, inspects objects and turns matches into findings.
Inventory S3 buckets: Access, sharing and encryption settings are evaluated.
Sample or scan objects: Automated discovery samples; jobs scan targets fully.
Match data identifiers: Managed and custom identifiers classify content.
Produce findings: Policy and sensitive data findings with severity.
Route to EventBridge: Alert, quarantine or ticket the affected objects.
Code examples
Create a custom identifier and a one-time job
# Custom identifier for an Indian PAN-style value (5 letters, 4 digits, 1 letter)
aws macie2 create-custom-data-identifier \
--name pan-number \
--regex "[A-Z]{5}[0-9]{4}[A-Z]" \
--keywords PAN "permanent account number" \
--maximum-match-distance 50
# One-time job over a single bucket using all managed identifiers
aws macie2 create-classification-job \
--job-type ONE_TIME --name kyc-audit \
--custom-data-identifier-ids <id-from-previous-command> \
--s3-job-definition '{
"bucketDefinitions": [
{ "accountId": "111122223333", "buckets": ["kyc-uploads-prod"] }
]
}'
Keywords near the match reduce false positives, so a random 10-character code is not flagged unless words like PAN appear nearby.
Key points
Macie works on Amazon S3 only.
Two outputs: policy findings (bucket posture) and sensitive data findings (object contents).
Automated discovery samples broadly; classification jobs scan targeted data fully.
Managed identifiers cover PII, financial data and credentials; custom identifiers use regex plus keywords.
Findings go to EventBridge and Security Hub for alerting and remediation.
Common follow-up questions
How is Macie different from GuardDuty?
How would you reduce Macie costs on a very large data lake?
How would you automatically quarantine an object with exposed credentials?
How do you find PII stored in RDS if Macie only covers S3?
Interview tips
Lead with 'S3-only sensitive data discovery plus bucket posture'; vague answers about 'ML security' sound memorized.
Mention cost control through automated discovery and targeted jobs.
Tie it to a compliance need such as DPDP, PCI DSS or KYC data to show practical understanding.
Concepts covered
Sensitive Data Discovery, Managed Data Identifiers, PII, S3 Bucket Security, Data Classification