この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
以下 GuardDuty のベストプラクティスなセットアップをなるべく楽ちんに行います。
- Amazon GuardDutyを Organizations環境内の 全てのアカウントの全てのリージョンで有効化する
- 『S3 データアクセスイベントの脅威検出』※ も自動有効化する
- 今後追加されたメンバーアカウントに対して自動で上記の有効化を行う
※参考: 【アップデート】 Amazon GuardDuty で S3 への不審なアクティビティを脅威検出できるようになりました! | DevelopersIO
なお GuardDuty の Organizations連携の説明自体は以下を参照ください。
【Organizations】組織内の GuardDuty設定を試してみる | DevelopersIO
1. 『信頼されたアクセス』を有効化する
マネジメントコンソールの AWS Organizations の [サービス] へ移動します。 GuardDuty を 「アクセス有効」 にしておきましょう。 Organizations 連携を活用するために必要です。
※もし「GuardDuty コンソールから有効化することお勧めします」な表示が出た場合は、 気にせず有効にしましょう。
2. 管理アカウントで GuardDuty を有効化する
Organizations 連携で 基本的にメンバーアカウントの GuardDuty は自動で有効化されます。 しかし 管理アカウントは例外です 。
なので 管理アカウント上で 全リージョン GuardDuty を有効化しておきます。
AWS CloudShell もしくはローカルから AWS CLI を実行します。
aws ec2 describe-regions --query "Regions[].[RegionName]" --output text \
| while read region; do
echo "##### enable GuardDuty in ${region}"
aws --region ${region} guardduty create-detector --enable
done
確認コマンドはこちら
aws ec2 describe-regions --query "Regions[].[RegionName]" --output text \
| while read region; do
echo "##### list GuardDuty detectors in ${region}"
aws --region ${region} guardduty list-detectors
done
3. メンバーアカウントへ委任する
特定メンバーアカウント(Audit用アカウントなど)に GuardDuty を委任します。
同じく CloudShell もしくはローカルから AWS CLI を実行します。
adminAccount=123456789012
aws ec2 describe-regions --query "Regions[].[RegionName]" --output text \
| while read region; do
echo "##### enable organization admin account in ${region}"
aws --region ${region} guardduty enable-organization-admin-account \
--admin-account-id ${adminAccount}
done
4. メンバーアカウントで GuardDuty セットアップ
この作業はマネコンの一括設定が便利なのでポチポチしていきます。
ここからは委任先のメンバーアカウントへログインします。
GuardDuty の [設定] > [アカウント] ページに行きましょう。 ポップアップが出てきますが無視して、以下の 『(ー) 自動有効化はOFF』 をクリックしてください。
2つのトグル(「GuardDuty の自動有効化」と「S3保護の自動有効化」)を ONにして [設定を更新] を選択します。
次にリストされているアカウントを全て選択して、 [アクション] > [メンバーを追加] を選択します。
以下のような画面になっていればOKです。
- 『自動有効化はON』となっていること
- 『ステータス/S3保護』両方とも有効になっていること
この作業を 全リージョン分、ぽちぽちと設定してきましょう。
5. チェック
これで設定完了です。
確認する場合は以下 AWS CLIコマンドを委任先メンバーアカウント上で実施しましょう。
aws ec2 describe-regions --query "Regions[].[RegionName]" --output text \
| while read region; do
echo "##### check: ${region}"
detector=$(aws --region ${region} guardduty list-detectors \
--query "DetectorIds[0]" --output text)
echo "# Describe organizations configuration"
aws --region ${region} guardduty describe-organization-configuration \
--detector-id ${detector} --output table \
--query "{AutoEnablle:AutoEnable, S3LogsAutoEnable:DataSources.S3Logs.AutoEnable}"
echo "# list members in ${region}"
aws --region ${region} guardduty list-members --detector-id ${detector} \
--query "Members[].[AccountId,RelationshipStatus]" --output table
done
# ##### check: eu-north-1
# # Describe organizations configuration
# -------------------------------------
# | DescribeOrganizationConfiguration |
# +--------------+--------------------+
# | AutoEnablle | S3LogsAutoEnable |
# +--------------+--------------------+
# | True | True |
# +--------------+--------------------+
# # list members in eu-north-1
# -----------------------------
# | ListMembers |
# +---------------+-----------+
# | 12345678901x | Enabled |
# | 12345678901x | Enabled |
# | 12345678901x | Enabled |
# | 12345678901x | Enabled |
# | 12345678901x | Enabled |
# | 12345678901x | Enabled |
# +---------------+-----------+
# ##### check: ap-south-1
# # Describe organizations configuration
# -------------------------------------
# | DescribeOrganizationConfiguration |
# (略)
すべて True もしくは Enabled となっていればOKです。
おわりに
Organizations 環境の GuardDuty セットアップを行ってみました。
GuardDutyの通知方法や実運用などの情報は以下ブログ参照ください。
- 【2021年版】Amazon GuardDutyによるAWSセキュリティ運用を考える | DevelopersIO
- GuardDutyからのイベント通知をちょっと見やすくして通知する | DevelopersIO
- 【全リージョン対応】EventBridge + SNS + Chatbotで GuardDutyの結果を Slackチャンネルに通知する | DevelopersIO