やること
下記のCloudTrail Insightsの通知メールをカスタマイズする。
amegaeru.hatenablog.jp
実践!
1.作成済みのEventBridgeルールに入力トランスフォーマーを設定
1-1.[AWS] - [EventBridge] - [ルール]
1-2.作成済みのEventBridgeルールを選択
1-3.[ターゲット]タブ
1-4.[編集]
1-5.[追加設定]のプルダウンを開き、[ターゲット入力を設定]から[入力トランスフォーマー]を選択
1-6.[入力トランスフォーマーを設定]
1-7.[入力パス]と[テンプレート]に下記を入力
※CloudTrail Insightsのイベント内容のサンプルを見たい場合は、[サンプルイベント]から[CloudTrail Insights]を選択
入力パス
※イベントを変数に格納するイメージ
※キー名に[.(ドット)]は使用不可
{ "version": "$.version", "id": "$.id", "detail-type": "$.detail-type", "source": "$.source", "account": "$.account", "time": "$.time", "region": "$.region", "resources": "$.resources", "eventVersion": "$.detail.eventVersion", "eventTime": "$.detail.eventTime", "awsRegion": "$.detail.awsRegion", "eventID": "$.detail.eventID", "eventType": "$.detail.eventType", "recipientAccountId": "$.detail.recipientAccountId", "sharedEventID": "$.detail.sharedEventID", "insightDetails_state": "$.detail.insightDetails.state", "insightDetails_eventSource": "$.detail.insightDetails.eventSource", "insightDetails_eventName": "$.detail.insightDetails.eventName", "insightDetails_insightType": "$.detail.insightDetails.insightType", "baseline_average": "$.detail.insightDetails.insightContext.statistics.baseline.average", "insight_average": "$.detail.insightDetails.insightContext.statistics.insight.average", "insightDuration": "$.detail.insightDetails.insightContext.statistics.insightDuration", "eventCategory": "$.detail.eventCategory" }
テンプレート
※ダブルクォーテーションは必須
"メッセージもかけるよ!" "version:<version>" "id:<id>" "detail-type:<detail-type>" "source:<source>" "account:<account>" "time:<time>" "region:<region>" "resources:<resources>" "detail.eventVersion:<eventVersion>" "detail.eventTime:<eventTime>" "detail.awsRegion:<awsRegion>" "detail.eventID:<eventID>" "detail.eventType:<eventType>" "detail.recipientAccountId:<recipientAccountId>" "detail.sharedEventID:<sharedEventID>" "detail.insightDetails.state:<insightDetails_state>" "detail.insightDetails.eventSource:<insightDetails_eventSource>" "detail.insightDetails.eventName:<insightDetails_eventName>" "detail.insightDetails.insightType:<insightDetails_insightType>" "baseline.average:<baseline_average>" "insight.average:<insight_average>" "insightDuration:<insightDuration>" "eventCategory:<eventCategory>"
1-8.[ルールを更新]
2.動作確認
2-1.イベントを発行しメールを送信させる
2-2.メールの本文がテンプレート通りになっていること
感想
メールタイトルも変えれればいいのにな。あとはLambdaをかませるほかなさそう。。。