Sensitive Data Discovery Tools

How to find PII in Amazon S3: three routes, worked through

Three routes find PII in Amazon S3: Amazon Macie (an automated discovery setting or a job), Google Sensitive Data Protection discovery (Security Command Center Enterprise only), and open-source Presidio or TruffleHog run over objects you read yourself. At list prices on December 4, 2026, one full Macie job over 100 TB in 100 buckets costs $75,000 in a month once the 5 TB monthly job quota is raised.

Last reviewed ยท Markdown version

Key facts

  • In an AWS Organizations setup, only the account that creates a Macie job can see that job's sensitive data findings, and only the administrator can see those from automated discovery (AWS docs, read December 4, 2026).
  • TruffleHog's README says it finds credentials; it is a secrets scanner, so it does not replace a personal-data detector (README, December 4, 2026).
  • Presidio's FAQ calls it a library or SDK rather than a service, so the code that lists and reads S3 objects is yours to write (Presidio FAQ, December 4, 2026).

The three routes

What each route does with S3, December 4, 2026
Route How it reads S3 What you must supply
Amazon Macie Managed service inside your AWS account; automated sampling or a job you define Permissions, a results bucket and KMS key
Google Sensitive Data Protection discovery Google reads a sample of each bucket over the internet through an AWS role Security Command Center Enterprise, an AWS connector, an inspection template
Presidio and TruffleHog Code or a CLI you run, with your own AWS credentials Compute, a reader for each file format, the review of results

The shadow data guide covers why unknown buckets matter first; the PII discovery tools directory lists tools beyond S3. The head-to-head of the first two routes is Macie vs Google Sensitive Data Protection.

Route 1: Amazon Macie

Enable Macie

  1. Attach the AWS managed policy AmazonMacieFullAccess to the IAM identity that will set Macie up (AWS docs).
  2. In the Region where the buckets are, enable Macie. Macie is regional, and so is everything below. The console path is Get started, then Enable Macie. From the CLI, the enable-macie command takes --status and --finding-publishing-frequency (AWS CLI reference):
aws macie2 enable-macie --region us-east-1 --status ENABLED
  1. Within minutes Macie builds an inventory of general purpose buckets in that Region, and depending on account settings starts automated discovery, with first results typically within 48 hours (AWS docs).

The macie2 commands below, other than the three multi-account ones, are built from the option syntax in the AWS CLI reference, which prints no examples. The values are AWS's own placeholders: Region us-east-1, account 111122223333, bucket amzn-s3-demo-bucket and the sample key ARN.

Choose automated discovery or a job

Macie finds sensitive data in two ways (AWS docs):

  • Automated sensitive data discovery evaluates the inventory daily, groups objects by bucket, prefix, storage class, extension and modified date, and analyzes a representative sample from each group. It prioritizes breadth: buckets not yet analyzed come first (AWS docs). Turn it on or off with update-automated-discovery-configuration (AWS CLI reference):
aws macie2 update-automated-discovery-configuration --region us-east-1 --status ENABLED
  • A sensitive data discovery job analyzes the buckets and objects you scope, once or on a daily, weekly or monthly schedule, at a sampling depth you set as a percentage of objects. Macie reads every chosen object in full (AWS docs). Use a job when you must state what was covered, for example for an audit.

A one-time job over named buckets, using the bucketDefinitions shape the CLI reference prints:

aws macie2 create-classification-job --region us-east-1 \
  --job-type ONE_TIME --name s3-pii-audit --sampling-percentage 100 \
  --s3-job-definition '{"bucketDefinitions":[{"accountId":"111122223333","buckets":["amzn-s3-demo-bucket"]}]}'

For a recurring job that follows your inventory, replace bucketDefinitions with bucketCriteria. A job definition holds one or the other, and criteria are evaluated each time the job runs (AWS CLI reference):

aws macie2 create-classification-job --region us-east-1 \
  --job-type SCHEDULED --schedule-frequency '{"weeklySchedule":{"dayOfWeek":"SUNDAY"}}' \
  --name s3-pii-weekly --sampling-percentage 100 \
  --s3-job-definition '{"bucketCriteria":{"includes":{"and":[{"simpleCriterion":{"comparator":"EQ","key":"ACCOUNT_ID","values":["111122223333"]}}]}}}'

If --managed-data-identifier-selector is left out, the job uses the recommended set of managed data identifiers (AWS CLI reference). For a recurring job, --initial-run decides whether existing objects are analyzed right away.

Set up the results repository

Macie keeps discovery results for 90 days, and AWS says to configure a repository bucket within 30 days of enabling Macie (AWS docs). The repository needs an S3 general purpose bucket, a customer managed symmetric KMS key in the same Region as the bucket, a key policy statement that lets macie.amazonaws.com call kms:GenerateDataKey and kms:Encrypt, and, for a bucket you create yourself, a bucket policy that lets Macie add objects (AWS docs). Macie writes gzip-compressed JSON Lines files with SSE-KMS. A result never contains the sensitive data itself. It records the locations, up to 1,000 occurrences per data type in an object.

Set the repository with put-classification-export-configuration, whose s3Destination takes bucketName, keyPrefix and kmsKeyArn (AWS CLI reference):

aws macie2 put-classification-export-configuration --region us-east-1 \
  --configuration '{"s3Destination":{"bucketName":"amzn-s3-demo-bucket","keyPrefix":"macie-results/","kmsKeyArn":"arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"}}'

The Terraform equivalent, from the provider's documentation example with the names changed (Terraform docs):

resource "aws_macie2_account" "this" {}

resource "aws_macie2_classification_export_configuration" "this" {
  depends_on = [aws_macie2_account.this]
  s3_destination {
    bucket_name = aws_s3_bucket.macie_results.bucket
    key_prefix  = "macie-results/"
    kms_key_arn = aws_kms_key.macie_results.arn
  }
}

The repository setting applies to one Region. For several Regions, set it in each, in a bucket that follows the opt-in Region rules on the AWS page. AWS publishes Athena sample queries for the results on GitHub, linked from that page.

Cover many accounts

The management account of an AWS Organizations organization names a delegated Macie administrator, which can then enable Macie for members and run discovery on their buckets. AWS prints these commands, which repeat in every Region; the create-member quoting is changed from AWS's Windows form to bash (AWS docs):

aws macie2 enable-organization-admin-account --region us-east-1 --admin-account-id 111122223333
aws macie2 update-organization-configuration --region us-east-1 --auto-enable
aws macie2 create-member --region us-east-1 --account='{"accountId":"123456789012","email":"janedoe@example.com"}'

The first runs in the management account. The other two run in the administrator account. Auto-enable affects new accounts only; existing accounts must be added with create-member. Results from a member's buckets are stored in the administrator's repository (AWS docs), and one administrator can select up to 1,000 buckets across up to 1,000 accounts for a single job (AWS docs).

What Macie does not read

Macie analyzes only objects in general purpose buckets that use one of six storage classes: Reduced Redundancy, S3 Glacier Instant Retrieval, S3 Intelligent-Tiering, S3 One Zone-IA, S3 Standard and S3 Standard-IA. S3 Glacier Deep Archive, S3 Express One Zone and directory buckets are skipped (AWS docs). It reads Avro, Parquet, gzip, TAR, ZIP, PDF, Word, Excel, EML and non-binary text, and does not analyze images, audio or video. Skipped objects are counted as unclassifiable, and the bucket inventory reports how many each bucket holds. AWS suggests exporting RDS or Aurora snapshots as Parquet, or DynamoDB tables, to S3 to bring them in scope.

Quotas that change a plan

  • Jobs may analyze 5 TB per account per month by default. Service Quotas raises that to 1,000 TB (1 PB), and AWS Support handles more (AWS docs).
  • Files over these sizes are not analyzed at all: 20 GB for text, TAR and EML; 8 GB for Avro, Parquet, gzip and ZIP; 1,024 MB for PDF; 512 MB for Word and Excel.
  • Archives are opened to 10 nested levels and 1,000,000 files, with 10 GB of uncompressed data overall.
  • Only the 10,000 most recently created or changed buckets in an account get full monitoring.
  • The CreateClassificationJob operation is limited to 0.1 requests per second.

Worked cost: 100 TB in 100 buckets

Macie bills sensitive data discovery per GB analyzed, per month, per account: $1.00 for the first 50 TB, $0.50 for the next 450 TB and $0.25 above 500 TB, plus $0.10 per bucket per month; new accounts get a 30-day trial that inspects up to 150 GB (Macie pricing, US East, N. Virginia). Decimal units, so 100 TB is 100,000 GB.

  • One full job in one month, after the quota is raised: 50,000 GB x $1.00 + 50,000 GB x $0.50 = $75,000, plus 100 buckets x $0.10 = $10 for monitoring.
  • S3 requests for the job, at the same 1 MB average object as Route 3 (100,000,000 objects): GET, 100,000,000 / 1,000 x $0.0004 = $40; LIST, 100,000,000 keys / 1,000 per call = 100,000 calls x $0.005 per 1,000 = $0.50. The Macie pricing page says jobs incur these standard S3 GET and LIST charges (Macie pricing, S3 pricing).
  • The same job held to the default 5 TB quota: when the quota is reached Macie pauses the job, and it resumes in the next calendar month (Macie pricing FAQ). That takes 20 months, and each month restarts the tiers: 20 x (5,000 GB x $1.00) = $100,000, plus 20 x $10 = $200 for bucket monitoring.
  • A job at 10% sampling depth, assuming the sampled objects hold 10% of the bytes: 10,000 GB x $1.00 = $10,000.
  • Automated discovery bills the bytes it samples on the same tiers. AWS does not publish how many bytes that is for a given estate. It also bills object monitoring at $0.01 per 100,000 objects a month: 100,000,000 / 100,000 x $0.01 = $10 a month, on top of the $10 bucket charge.

The same arithmetic at 2 PB is on the 2 PB S3 result page.

Route 2: Google Sensitive Data Protection discovery for S3

Google's page says this feature is open only to customers with Security Command Center at the Enterprise tier (Google docs). It produces a profile per bucket (file clusters, sensitivity level and the types of sensitive information found), not a finding per object.

What it needs on the AWS side

Google reaches AWS through a Security Command Center connector with two kinds of AWS account (Google docs):

  • A delegated account that authenticates to Google Cloud. It must belong to an AWS organization and be the management account, a delegated administrator, or an account with a resource-based delegation policy that grants organizations:ListAccounts.
  • Collector accounts, in the same organization, each with a collector role. The connector page offers CloudFormation templates, run as a stack set from the management account, or manual role and policy creation.

Keeping the box Grant permissions for Sensitive Data Protection discovery selected adds a Sensitive Data Protection collector role. Its S3 permissions are s3:GetBucketLocation, s3:ListAllMyBuckets, s3:GetBucketPolicyStatus, s3:ListBucket, s3:GetObject, s3:GetObjectVersion, s3:GetBucketPublicAccessBlock, s3:GetBucketOwnershipControls and s3:GetBucketTagging. The same checkbox also grants IAM, Cost Explorer, DynamoDB, Lambda and other read permissions listed on the connector page (Google docs).

Steps

  1. In Security Command Center, create the AWS connector with the discovery permissions checkbox selected, or grant them to an existing connector.
  2. Create an inspection template in the global region or in the region where the scan configuration and profiles will be stored.
  3. In Sensitive Data Protection, create a scan configuration at organization level, choose Amazon S3, and set the scope: all accounts the connector reaches, one account, or one bucket. Add schedules, filters on account ID or bucket name (RE2 expressions), and optionally restrict to storage classes such as S3 Standard and S3 Glacier Instant Retrieval (Google docs).
  4. Choose actions: publish to Security Command Center or Google Security Operations, save profile copies to BigQuery, or send Pub/Sub notifications.

Data profiles are stored in the region of the scan configuration, not in the AWS Region of the data, and Google makes no guarantee about where data passes after it reaches the public internet (Google docs).

Worked cost: 100 TB in 100 buckets

Discovery scans a sample from each bucket, and the data transferred per bucket usually does not exceed 30 GB. AWS charges for requests and for transfer out to the internet, and Google's own example uses $0.09 per GB, $0.005 per 1,000 LIST calls and $0.0004 per 1,000 GET calls (Google docs). The AWS side for 100 buckets of S3 Standard, per profiling pass:

  • Transfer, in most cases at most: 100 x 30 GB = 3,000 GB x $0.09 = $270. Google says retries after intermittent errors can exceed 30 GB. AWS gives the first 100 GB a month out to the internet free, aggregated across services (S3 pricing).
  • GET requests, about 4 per file for up to 7,000 files per bucket: 4 x 7,000 x 100 = 2,800,000 x $0.0004 per 1,000 = $1.12.
  • LIST requests, about 50 per bucket per day: 50 x 100 = 5,000 a day x $0.005 per 1,000 = $0.025 a day.

These AWS charges follow the number of buckets, not the 100 TB, because the sample is capped per bucket. On the Google side, discovery is included at no extra charge in an organization-level Enterprise subscription (Google pricing). Enterprise is priced at 5% of projected annual Google Cloud spend for organizations spending under $15 million a year, plus a percentage of that for other clouds by size, with a $15,000 annual minimum (Security Command Center pricing). The price follows Google Cloud spend, not S3 volume. An organization whose annual Google Cloud spend is under $300,000 (5% of which is $15,000) pays at least the $15,000 annual minimum, before the other-clouds component.

Route 3: Presidio and TruffleHog over S3 objects

Neither tool is an S3 PII scanner on its own. TruffleHog has an s3 source but is a secrets scanner. Presidio detects personal data but only in text you pass it.

TruffleHog: credentials in S3 objects

The README documents a scan of one bucket with locally set credentials or instance metadata, and of a bucket through an assumed role (README):

trufflehog s3 --bucket=<bucket-name> --role-arn=<iam-role-arn>

To limit the scan to one key prefix, the README documents --include-prefix, which is matched literally against the object key before download and can be repeated:

trufflehog s3 --bucket=<bucket-name> --include-prefix=db-reporting/data/ --results=verified,unknown

Related flags: --exclude-prefix, --include-extension and --exclude-extension (the last two cannot be combined), and --ignore-bucket. Exclusions are applied after listing, so they cut downloads but not LIST calls. Results are verified, unverified or unknown, depending on an API test of the credential. A custom regex detector in a config file can match other patterns; in issue 4374 a TruffleHog contributor posted one for street addresses run against an S3 source.

Presidio: PII in S3 text

Install the analyzer and a spaCy model, as the installation page prints (Presidio docs):

pip install presidio_analyzer
python -m spacy download en_core_web_lg

The analyzer call below is from Presidio's analyzer page (Presidio docs). The S3 listing and reading around it is this site's sketch, using the paginator from the boto3 documentation. It reads only text-like keys, takes the first 1,000,000 bytes of each (a limit this site chose), and prints entity type, score and offsets without the matched text:

import sys

import boto3
from presidio_analyzer import AnalyzerEngine

bucket, prefix = sys.argv[1], sys.argv[2]
s3 = boto3.client("s3")
analyzer = AnalyzerEngine()

pages = s3.get_paginator("list_objects_v2").paginate(Bucket=bucket, Prefix=prefix)
for page in pages:
    for obj in page.get("Contents", []):
        key = obj["Key"]
        if not key.endswith((".txt", ".csv", ".json", ".log")):
            continue
        body = s3.get_object(Bucket=bucket, Key=key)["Body"].read(1_000_000)
        text = body.decode("utf-8", errors="replace")
        for hit in analyzer.analyze(text=text, language="en"):
            print(key, hit.entity_type, round(hit.score, 2), hit.start, hit.end)

Parquet, Avro, PDF, Word and Excel need a reader that turns each into text before the analyzer sees it; Presidio has a structured data module for DataFrames and JSON. Detection quality is yours to tune: the benchmark measures three open-source detectors on public test data, and Presidio vs managed detection APIs sets it beside the hosted services.

Worked cost: 100 TB in 100 buckets

The Scan Price File lists both licenses at $0 (MIT for Presidio, AGPL-3.0 for TruffleHog). The charges are the ones AWS bills for reading. Assume an average object of 1 MB, so 100 TB is 100,000,000 objects. S3 Standard GET requests cost $0.0004 per 1,000 (S3 pricing):

  • GET requests: 100,000,000 / 1,000 x $0.0004 = $40.
  • LIST requests: 100,000,000 keys / 1,000 per call = 100,000 calls x $0.005 per 1,000 = $0.50.
  • Transfer: $0 when the scanner runs on EC2 in the bucket's Region, because S3 lists transfer to an AWS service in the same Region among the free transfers (S3 pricing).
  • Compute: not priced. Neither project publishes a throughput figure, so hours per terabyte, and the instance bill, come from a trial on your own data.

The scan cost calculator runs the managed lists on other volumes.

Questions readers ask

Why does Macie not list my new S3 bucket when I create a job?

The asker found the cause was Region: the job was in a different Region from the bucket. A job's bucket picker lists general purpose buckets in the console's current Region only (Getting started with Macie). A job with explicitly selected buckets does not gain buckets created later.

Asked at stackoverflow.com

Can Terraform create the results repository bucket for Macie discovery?

The asker had aws_macie2_account but no repository setting; the missing resource is aws_macie2_classification_export_configuration, shown under Set up the results repository with the KMS and bucket policies it needs.

Asked at stackoverflow.com

How do I query Macie results across 40+ accounts for a GDPR discovery project?

Query the administrator's repository bucket with Athena, using the sample queries described under Set up the results repository; members' results land in that one bucket, so no per-account query is needed.

Asked at repost.aws

What is the right TruffleHog config file structure for scanning an S3 prefix?

In the multi-scan YAML, a TruffleHog contributor said in August 2025 that the S3 source had no prefix or region field. The README for release v3.100.1 documents prefix filtering as flags on the s3 command instead.

Asked at github.com

Sources

  1. Getting started with Macie
  2. Macie supported storage classes and formats
  3. Quotas for Macie
  4. Storing and retaining sensitive data discovery results
  5. Integrating and configuring an organization in Macie
  6. Macie administrator and member account relationships
  7. How automated sensitive data discovery works
  8. Defining the scope of a discovery job
  9. AWS CLI reference: macie2 create-classification-job
  10. AWS CLI reference: macie2 enable-macie
  11. AWS CLI reference: macie2 put-classification-export-configuration
  12. AWS CLI reference: macie2 update-automated-discovery-configuration
  13. Amazon Macie pricing
  14. Amazon S3 pricing
  15. Sensitive data discovery for Amazon S3
  16. Profile Amazon S3 data
  17. Connect Security Command Center to AWS
  18. Sensitive Data Protection pricing
  19. Security Command Center pricing
  20. TruffleHog README
  21. TruffleHog issue 4374: S3 config file structure
  22. Presidio installation
  23. Presidio analyzer
  24. Presidio structured data
  25. Presidio FAQ
  26. Terraform AWS provider: aws_macie2_classification_export_configuration
  27. boto3 ListObjectsV2 paginator
  28. Stack Overflow: Macie job not showing new bucket
  29. Stack Overflow: Terraform for the Macie results repository
  30. AWS re:Post: Macie across a multi-account S3 estate