Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement Amazon Macie to automatically discover, classify, and protect sensitive data in S3 buckets using machine learning and pattern matching for PII, financial data, and credentials detection.
.claude/skills/implementing-aws-macie-for-data-classification/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-15 | ✗→✓ | ▲ Improved | — | — |
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-11 | ✗→✓ | ▲ Improved | — | — |
Amazon Macie is a fully managed data security and privacy service that uses machine learning and pattern matching to discover and protect sensitive data in Amazon S3. Macie automatically evaluates your S3 bucket inventory on a daily basis and identifies objects containing PII, financial information, credentials, and other sensitive data types. It provides two discovery approaches: automated sensitive data discovery for broad visibility and targeted discovery jobs for deep analysis.
bash# Enable Macie in the current account/region aws macie2 enable-macie # Verify Macie is enabled aws macie2 get-macie-session # Enable automated sensitive data discovery aws macie2 update-automated-discovery-configuration \ --status ENABLED
hclresource "aws_macie2_account" "main" {} resource "aws_macie2_classification_export_configuration" "main" { depends_on = [aws_macie2_account.main] s3_destination { bucket_name = aws_s3_bucket.macie_results.id key_prefix = "macie-findings/" kms_key_arn = aws_kms_key.macie.arn } }
bashaws macie2 create-classification-job \ --job-type ONE_TIME \ --name "pii-scan-production-buckets" \ --s3-job-definition '{ "bucketDefinitions": [{ "accountId": "123456789012", "buckets": [ "production-data-bucket", "customer-records-bucket" ] }] }' \ --managed-data-identifier-selector ALL
bashaws macie2 create-classification-job \ --job-type SCHEDULED \ --name "weekly-sensitive-data-scan" \ --schedule-frequency-details '{ "weekly": { "dayOfWeek": "MONDAY" } }' \ --s3-job-definition '{ "bucketDefinitions": [{ "accountId": "123456789012", "buckets": ["all-data-bucket"] }], "scoping": { "includes": { "and": [{ "simpleScopeTerm": { "comparator": "STARTS_WITH", "key": "OBJECT_KEY", "values": ["uploads/", "documents/"] } }] } } }'
bashaws macie2 create-custom-data-identifier \ --name "internal-employee-id" \ --description "Matches internal employee ID format EMP-XXXXXX" \ --regex "EMP-[0-9]{6}" \ --severity-levels '[ {"occurrencesThreshold": 1, "severity": "LOW"}, {"occurrencesThreshold": 10, "severity": "MEDIUM"}, {"occurrencesThreshold": 50, "severity": "HIGH"} ]'
bashaws macie2 create-custom-data-identifier \ --name "project-code-identifier" \ --description "Matches project codes in format PRJ-XXXX-XX" \ --regex "PRJ-[A-Z]{4}-[0-9]{2}" \ --keywords '["project", "code", "initiative"]' \ --maximum-match-distance 50
bashaws macie2 create-allow-list \ --name "test-data-exclusions" \ --description "Exclude known test data patterns" \ --criteria '{ "regex": "TEST-[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}" }'
Macie provides 300+ managed data identifiers covering:
| Category | Examples | |----------|---------| | PII | SSN, passport numbers, driver's license, date of birth, names, addresses | | Financial | Credit card numbers, bank account numbers, SWIFT codes | | Credentials | AWS secret keys, API keys, SSH private keys, OAuth tokens | | Health | HIPAA identifiers, health insurance claim numbers | | Legal | Tax identification numbers, national ID numbers |
bash# Get sensitive data findings aws macie2 list-findings \ --finding-criteria '{ "criterion": { "severity.description": { "eq": ["High"] }, "category": { "eq": ["CLASSIFICATION"] } } }' \ --sort-criteria '{"attributeName": "updatedAt", "orderBy": "DESC"}' \ --max-results 25
bashaws macie2 get-findings \ --finding-ids '["finding-id-1", "finding-id-2"]'
bash# Macie automatically publishes findings to Security Hub # Verify integration: aws macie2 get-macie-session --query 'findingPublishingFrequency'
json{ "source": ["aws.macie"], "detail-type": ["Macie Finding"], "detail": { "severity": { "description": ["High", "Critical"] } } }
pythonimport boto3 import json s3 = boto3.client('s3') sns = boto3.client('sns') def lambda_handler(event, context): finding = event['detail'] severity = finding['severity']['description'] bucket = finding['resourcesAffected']['s3Bucket']['name'] key = finding['resourcesAffected']['s3Object']['key'] sensitive_types = [d['type'] for d in finding.get('classificationDetails', {}).get('result', {}).get('sensitiveData', [])] if severity in ['High', 'Critical']: # Tag the object for review s3.put_object_tagging( Bucket=bucket, Key=key, Tagging={ 'TagSet': [ {'Key': 'macie-finding', 'Value': severity}, {'Key': 'sensitive-data', 'Value': ','.join(sensitive_types)}, {'Key': 'requires-review', 'Value': 'true'} ] } ) # Notify security team sns.publish( TopicArn='arn:aws:sns:us-east-1:123456789012:security-alerts', Subject=f'Macie {severity} Finding: {bucket}/{key}', Message=json.dumps({ 'bucket': bucket, 'key': key, 'severity': severity, 'sensitive_data_types': sensitive_types, 'finding_id': finding['id'] }, indent=2) ) return {'statusCode': 200}
bash# From the management account aws macie2 enable-organization-admin-account \ --admin-account-id 111111111111
bash# From the administrator account aws macie2 create-member \ --account '{"accountId": "222222222222", "email": "security@example.com"}'
bashaws macie2 get-usage-statistics \ --filter-by '[{"comparator": "GT", "key": "accountId", "values": []}]' \ --sort-by '{"key": "accountId", "orderBy": "ASC"}'
bashaws macie2 list-classification-jobs \ --filter-criteria '{"includes": [{"comparator": "EQ", "key": "jobStatus", "values": ["RUNNING"]}]}'
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +23 percentage points is the difference between those two pass rates over the 21 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.