implementing-aws-macie-for-data-classification について
Amazon S3内の機密データを分類するAWS Macieの設定を解説するスキルです。AWSのデータセキュリティやコンプライアンスを担うチーム向けに、自動検出、対象指定スキャン、結果管理、複数アカウント展開を扱います。
主な機能
- 01機密データの自動検出を有効化
- 02単発または定期分類ジョブの作成
- 03カスタムデータ識別子と許可リストの設定
- 04検出結果の確認とエクスポート
- 05複数アカウントのMacieを一元管理
活用シーン
- 01S3バケット内の個人情報や金融情報のスキャン
- 02社内形式のプロジェクトコードの識別
- 03高重要度の検出結果を対応ワークフローへ連携
- 04複数のAWSアカウントでMacieを管理
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill implementing-aws-macie-for-data-classificationインストール後、Claude Code で/implementing-aws-macie-for-data-classificationを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
LICENSEassets/template.mdreferences/api-reference.mdstandards.mdworkflows.mdscripts/agent.pyprocess.py詳細
AWS Macie によるデータ分類の実装
概要
Amazon Macie は、機械学習とパターンマッチングを使用して Amazon S3 内の機微なデータを検出・保護する、フルマネージドのデータセキュリティおよびプライバシーサービスです。Macie は S3 バケットのインベントリを毎日自動的に評価し、PII、金融情報、認証情報、その他の機微なデータタイプを含むオブジェクトを特定します。広範な可視化のための自動機微データ検出と、詳細な分析のためのターゲット検出ジョブの 2 つの検出方式を提供します。
使用するタイミング
- 環境で implementing aws macie for data classification の機能をデプロイまたは構成するとき
- コンプライアンス要件に沿ったセキュリティ統制を確立するとき
- この領域のセキュリティアーキテクチャを構築または改善するとき
- この実装を必要とするセキュリティ評価を実施するとき
前提条件
- 分類対象のデータを含む S3 バケットがある AWS アカウント
- Macie サービス構成に対する IAM 権限
- AWS Organizations の設定(マルチアカウント展開の場合)
- サポートされているリージョンの S3 バケット
Macie の有効化
AWS CLI 経由
# 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
Terraform 経由
resource "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
}
}
検出ジョブの構成
特定のバケットに対する分類ジョブの作成
aws 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
定期実行ジョブの作成
aws 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/"]
}
}]
}
}
}'
カスタムデータ識別子
内部 ID 用のカスタム識別子の作成
aws 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"}
]'
プロジェクトコード用の識別子の作成
aws 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
許可リスト
誤検出を抑制するための許可リストの作成
aws 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 は、以下を対象とする 300 以上のマネージドデータ識別子を提供します。
| カテゴリ | 例 |
|---|---|
| PII | SSN、パスポート番号、運転免許証、生年月日、氏名、住所 |
| 金融 | クレジットカード番号、銀行口座番号、SWIFT コード |
| 認証情報 | AWS シークレットキー、API キー、SSH 秘密鍵、OAuth トークン |
| 医療 | HIPAA 識別子、健康保険の請求番号 |
| 法務 | 納税者番号、国民識別番号 |
検出結果の管理
検出結果の一覧表示
# 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
検出結果の詳細の取得
aws macie2 get-findings \
--finding-ids '["finding-id-1", "finding-id-2"]'
検出結果の Security Hub へのエクスポート
# Macie automatically publishes findings to Security Hub
# Verify integration:
aws macie2 get-macie-session --query 'findingPublishingFrequency'
自動対応のための EventBridge 連携
{
"source": ["aws.macie"],
"detail-type": ["Macie Finding"],
"detail": {
"severity": {
"description": ["High", "Critical"]
}
}
}
自動修復のための Lambda 関数
import 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}
マルチアカウント展開
Macie 管理者アカウントの指定
# From the management account
aws macie2 enable-organization-admin-account \
--admin-account-id 111111111111
メンバーアカウントの追加
# From the administrator account
aws macie2 create-member \
--account '{"accountId": "222222222222", "email": "[email protected]"}'
Macie の運用の監視
使用状況の統計
aws macie2 get-usage-statistics \
--filter-by '[{"comparator": "GT", "key": "accountId", "values": []}]' \
--sort-by '{"key": "accountId", "orderBy": "ASC"}'
分類ジョブのステータス
aws macie2 list-classification-jobs \
--filter-criteria '{"includes": [{"comparator": "EQ", "key": "jobStatus", "values": ["RUNNING"]}]}'
参考資料
- AWS Macie ドキュメント: https://docs.aws.amazon.com/macie/
- AWS Macie 料金
- Macie 分析でサポートされるファイルタイプ
- Macie による GDPR および CCPA への対応
コメント
Markdown 対応