AWS リソースが削除されたときにサービスイベントタイプで開始する Amazon EventBridge ルールを作成しました。ただし、レスポンスは JSON 形式です。カスタム通知を E メールで受け取るにはどうすればよいですか?
解決方法
EventBridge ルールでカスタムイベントパターンを使用して、 AWS Config でサポートされるリソースタイプに一致させます。次に、レスポンスを Amazon Simple Notification Service (Amazon SNS) トピックにルーティングします。
次の例では、Amazon Elastic Compute Cloud (Amazon EC2) インスタンスの終了終了時に SNS 通知を受信します。
注意: 特定の AWS のサービスのリソースタイプを置き換えることができます。
1. Amazon SNS トピックをまだ作成していない場合は、「Amazon SNS の開始方法」の手順に従ってください。
注意: Amazon SNS トピックは、AWS Config サービスと同じリージョンにある必要があります。
2. EventBridge コンソールを開き、ナビゲーションペインで [ルール] を選択します。
3. [Create rule] (ルールの作成) を選択します。
4. [Name] (名前) に、ルール名を入力します。
5. [Define pattern] (パターンを定義) で、[Event Pattern] (イベントパターン) を選択します。
6. [Event matching pattern] (イベント一致パターン) で [Custom pattern] (カスタムパターン) を選択します。
7. [Event pattern] (イベントパターン) プレビューペインで、次のイベントパターンの例をコピーして貼り付けます**。**
{
"source": [
"aws.config"
],
"detail-type": [
"Config Configuration Item Change"
],
"detail": {
"messageType": [
"ConfigurationItemChangeNotification"
],
"configurationItem": {
"configurationItemStatus": [
"ResourceDeleted"
]
}
}
}
8. [Target] (ターゲット) では、[SNS topic] (SNS トピック) を選択します。
9. [Topic] (トピック) で、ご自身の SNS トピックを選択します。
10. [Configure input] (入力を設定) を展開し、[Input transformer] (トランスフォーマーを入力) を選択します。
11. [Input Path] (入力パス) テキストボックスに、次のサンプルパスを入力します。
{
"awsRegion": "$.detail.configurationItem.awsRegion",
"awsAccountId": "$.detail.configurationItem.awsAccountId",
"resource_type": "$.detail.configurationItem.resourceType",
"resource_ID": "$.detail.configurationItem.resourceId",
"configurationItemCaptureTime": "$.detail.configurationItem.configurationItemCaptureTime"
}
12. [Input Template] (入力テンプレート) テキストボックスに、次のサンプルテンプレートを入力します。
"On <configurationItemCaptureTime> AWS Config service recorded a deletion of the resource <resource_ID> type <resource_type> in the account <awsAccountId> region <awsRegion>. For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=<awsRegion>#/timeline/<resource_type>/<resource_ID>/configuration"
13. [Create] (作成) をクリックします。
14. イベントタイプが開始されると、ステップ 12 で入力されたカスタム項目が記載された、次のような SNS の E メール通知を受け取ります。
"On ExampleTime AWS Config service recorded a deletion of the resource ExampleID type
ExampleResourceType in the account ExampleAccountID region ExampleRegion. For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=*ExampleRegion*#/timeline/*ExampleResourceType*/*ExampleID*/configuration"
関連情報
AWS Config サービスを使用して AWS アカウントでリソースが作成されたときに、カスタム E メール通知を受け取るにはどうすればよいですか ?
特定の AWS サービスイベントタイプがトリガーされた場合に、カスタム SNS 通知が送信されるように GuardDuty の EventBridge ルールを設定するにはどうすればよいですか?