Help us improve the AWS re:Post Knowledge Center by sharing your feedback in a brief survey. Your input can influence how we create and update our content to better support your AWS journey.
當 AWS Config 偵測到新資源時,如何設定自訂電子郵件通知?
我想使用 AWS Config 在 AWS Config 識別新資源時,接收電子郵件通知。
解決方法
**注意:**在下列範例中,當您建立新的 Amazon Elastic Compute Cloud (Amazon EC2) 執行個體時,您會收到 Amazon Simple Notification Service (Amazon SNS) 通知。當您在 AWS Config 服務處於活動狀態的 AWS 區域中建立 EC2 執行個體時,會出現通知。AWS Config 會記錄新的 EC2 執行個體,並使用資源類型 AWS::EC2::Instance 來辨識這些執行個體。
建立 Amazon SNS 主題
在與您的 AWS Config 服務相同的區域中建立 Amazon SNS 主題。
建立 EventBridge 規則
-
開啟 Amazon EventBridge console (Amazon EventBridge 主控台)。
-
在導覽窗格中,選擇 Rules (規則),然後選擇 Create rule (建立規則)。
-
輸入下列資訊:
對於 Name (名稱),輸入規則的名稱。
(選用) 對於 Description (描述),請輸入規則的描述。
在 Rule type (規則類型) 中,選擇 Rule with an event pattern (具有事件模式的規則)。 -
選擇 Next (下一步)。
-
在 Event source (事件來源) 中,選擇 AWS events or EventBridge partner events (AWS 事件或 EventBridge 合作夥伴事件)。
-
在 Event pattern (事件模式) 下,選擇 Custom pattern (JSON editor) (自訂模式 (JSON 編輯器))。
-
輸入下列事件模式範例:
{ "source": [ "aws.config" ], "detail-type": [ "Config Configuration Item Change" ], "detail": { "messageType": [ "ConfigurationItemChangeNotification" ], "configurationItem": { "resourceType": [ "AWS::EC2::Instance" ], "configurationItemStatus": [ "ResourceDiscovered" ] } } }**注意:**將 EC2::Instance 資源類型替換為您的資源類型。如需可用資源類型的清單,請參閱 ResourceIdentifier 中的 resourceType 一節。如需支援資源類型的資訊,請參閱AWS Config 支援的資源類型。
-
選擇 Next (下一步)。
-
輸入下列資訊:
對於 Target types (目標類型),選取 AWS service (AWS 服務)。
在 Select a target (選取目標),從下拉式清單中選取 SNS topic (SNS 主題)。
在 Topic (主題),選取您的 SNS 主題。 -
在 Additional settings (其他設定) 下,於 Configure target input (設定目標輸入) 中選擇 Input transformer (輸入轉換器)。
-
選擇 Configure input transformer (設定輸入轉換器)。然後,在 Target input transformer (目標輸入轉換器) 下的 Input path (輸入路徑) 文字方塊中,輸入下列範例路徑:
{ "awsRegion": "$.detail.configurationItem.awsRegion", "awsAccountId": "$.detail.configurationItem.awsAccountId", "resource_type": "$.detail.configurationItem.resourceType", "resource_ID": "$.detail.configurationItem.resourceId", "configurationItemCaptureTime": "$.detail.configurationItem.configurationItemCaptureTime" }
- 在 Template (範本) 文字方塊中,輸入下列範例範本:
"On <configurationItemCaptureTime> AWS Config service recorded a creation of a new <resource_type> with Id <resource_ID> 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"
- 選擇 Confirm (確認),然後選擇 Next (下一步)。
- 選擇 Create rule (建立規則)。
通知範例:
"On ExampleTime AWS Config service recorded a creation of a new AWS::EC2::Instance with Id ExampleID in the account AccountID region ExampleRegion. For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=*ExampleRegion*#/timeline/AWS::EC2::Instance/*ExampleID*/configuration"
相關資訊
- 語言
- 中文 (繁體)

相關內容
- 已提問 2 年前
AWS 官方已更新 5 個月前