概要
やりたいこと
Security Command Center のアラートを Slack 通知したい。
Cloud Pub/Sub + CloudFunctions で Slack 通知の仕方は以下。
Security Command Center については以下。
アーキテクチャ
下記を参考にする。
全体の流れ。
- Security Command Center -> NotificationConfig(GCS?) -> Pub/Sub Topic -> Cloud Functions -> Slack
SCC から Cloud Pub/Sub への通知は NotificationConfig を作成する必要がある(Storage Transfer Service とは別?)。
つまり、SCC のアラートは GCS に保存されているのだろうか?
Security Command Center は組織アカウントに作成し、Cloud Pub/Sub, Cloud Functions は別プロジェクトに作成する。
NotificationConfig とは
GCS には、バケット内のオブジェクトに変更が加えられると、その情報を Pub/Sub に送信する機能がある。
NotificationConfig は Cloud Pub/Sub にパブリッシュする通知を構成する仕様を定義する。
次の3つから構成される。
- 通知を受信する Pub/Sub トピック
- 通知の送信をトリガーするイベント
- 通知に含まれる情報
Terraform と gcloud
※ Terraform 実行用のサービスロールは簡単化のためオーナー権限
Pub/Sub Topic 作成
以下をやる。
gcloud で NotificationConfig 作成
組織管理者権限が付与されたアカウントに gcloud でログイン。
gcloud auth login
確認。
gcloud auth list
gcloud scc notifications コマンドを利用する。
organization と pubsub-topic は適宜修正。
gcloud scc notifications create notification-test \
--organization "111122223333" \
--description "Notifies for active findings" \
--pubsub-topic "projects/PROJECT_ID/topics/example-topic" \
--filter "state=\"ACTIVE\""
設定後、下記のように Slack にアラートが届けば成功。

コメント