

• 2026 年 4 月 30 日之後將不再提供 AWS Systems Manager CloudWatch Dashboard。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板，就像現在一樣。如需詳細資訊，請參閱 [Amazon CloudWatch Dashboard 文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 根據 Parameter Store 事件設定通知或觸發動作
<a name="sysman-paramstore-cwe"></a>

本節中的主題說明如何使用 Amazon EventBridge 和 Amazon Simple Notification Service (Amazon SNS) 來通知您 AWS Systems Manager 參數的變更。您可以建立 EventBridge 規則，在參數或參數標籤版本建立、更新或遭到刪除時通知您。盡可能發出事件。您可以接收與參數政策相關變更或狀態的通知，例如參數過期、參數即將過期，或是在指定的時間期間內並未發生變更。

**注意**  
參數政策適用於使用進階參數方案的參數。需支付費用。如需詳細資訊，請參閱 [在 Parameter Store 中指派參數政策](parameter-store-policies.md) 及 [管理層](parameter-store-advanced-parameters.md)。

此部分的主題也說明了如何為特定參數事件，在目標上開啟其他動作。例如，您可以執行 AWS Lambda 函數，在參數過期或刪除時自動重新建立參數。您可以設定一個通知，在您的資料庫密碼更新時呼叫 Lambda 函數。Lambda 函數可以強制您的資料庫連線重設或以新的密碼重新連線。EventBridge 也支援執行Run Command命令和自動化執行，以及許多其他 中的動作 AWS 服務。 Run Command和 自動化都是其中的工具 AWS Systems Manager。如需詳細資訊，請參閱《[Amazon EventBridge 使用者指南](https://docs.aws.amazon.com/eventbridge/latest/userguide/)**》。

**開始之前**  
建立任何您需要的資源，為您建立的規則指定目標動作。例如，若您建立的規格是用來傳送通知，請先建立 Amazon SNS 主題。如需詳細資訊，請參閱《Amazon Simple Notification Service 開發人員指南》**中的 [Amazon SNS 入門](https://docs.aws.amazon.com/sns/latest/dg/sns-getting-started.htmlGettingStarted.html)。

## 為參數及參數政策設定 EventBridge
<a name="cwe-parameter-changes"></a>

本主題說明下列內容：
+ 如何建立 EventBridge 規則，根據您 AWS 帳戶帳戶中一或多個參數上發生的事件目標。
+ 如何建立 EventBridge 規則，根據您 AWS 帳戶帳戶中一或多個參數政策上發生的事件目標。當您建立進階參數時，您可以指定參數過期的時間、參數過期前何時要接收到通知，以及在參數沒有變更的情況下要等待多久的時間才傳送通知。您可以使用下列程序來設定這些事件的通知。如需詳細資訊，請參閱[在 Parameter Store 中指派參數政策](parameter-store-policies.md)及[管理層](parameter-store-advanced-parameters.md)。

**為 Systems Manager 參數或參數政策設定 EventBridge**

1. 前往 [https://console.aws.amazon.com/events/](https://console.aws.amazon.com/events/) 開啟 Amazon EventBridge 主控台。

1. 在導覽窗格中，選擇 **Rules** (規則)，然後選擇 **Create rule** (建立規則)。

   -或-

   如果 EventBridge 首頁先開啟，請選擇 **Create rule** (建立規則)。

1. 輸入規則的名稱和描述。

   在同一個區域和同一個事件匯流排上，規則不能與另一個規則同名。

1. 針對**事件匯流排**，選擇要與此規則建立關聯的事件匯流排。如果您希望此規則在來自您自己的相符事件上啟動 AWS 帳戶，請選取**預設 **。當您帳戶中 AWS 服務 的 發出事件時，一律會前往您帳戶的預設事件匯流排。

1. 針對 **Rule type** (規則類型)，請保持選取預設的 **Rule with an event pattern** (具有事件模式的規則)。

1. 選擇**下一步**。

1. 針對**事件來源**，請保持選取預設的 **AWS 事件或 EventBridge 合作夥伴事件**。您可以略過 **Sample event ** (示範活動) 部分。

1. 針對 **Event pattern** (事件模式) 請執行下列動作：
   + 選擇 **Custom patterns (JSON editor)** (自訂模式 (JSON 編輯器))。
   + 針對 **Event pattern** (活動模式)，將以下內容之一貼到方塊中，取決於是為參數還是為參數政策建立規則：

------
#### [ Parameter ]

     ```
     {
         "source": [
             "aws.ssm"
         ],
         "detail-type": [
             "Parameter Store Change"
         ],
         "detail": {
             "name": [
                 "{{parameter-1-name}}",
                 "/{{parameter-2-name}}/{{level-2}}",
                 "/{{parameter-3-name}}/{{level-2}}/{{level-3}}"
             ],
             "operation": [
                 "Create",
                 "Update",
                 "Delete",
                 "LabelParameterVersion"
             ]
         }
     }
     ```

------
#### [ Parameter policy ]

     ```
     {
         "source": [
             "aws.ssm"
         ],
         "detail-type": [
             "Parameter Store Policy Action"
         ],
         "detail": {
             "parameter-name": [
                 "{{parameter-1-name}}",
                 "/{{parameter-2-name}}/{{level-2}}",
                 "/{{parameter-3-name}}/{{level-2}}/{{level-3}}"
             ],
             "policy-type": [
                 "Expiration",
                 "ExpirationNotification",
                 "NoChangeNotification"
             ]
         }
     }
     ```

------
   + 修改參數的內容，以及您希望採取的動作，參閱以下範例。

------
#### [ Parameter ]

     在範例中，會在名為/`Oncall` 及 `/Project/Teamlead` 的參數更新時採取動作：

     ```
     {
         "source": [
             "aws.ssm"
         ],
         "detail-type": [
             "Parameter Store Change"
         ],
         "detail": {
             "name": [
                 "/Oncall",
                 "/Project/Teamlead"
             ],
             "operation": [
                 "Update"
             ]
         }
     }
     ```

------
#### [ Parameter policy ]

     在範例中，會在名為/`OncallDuties` 的參數過期或遭刪除時採取動作：

     ```
     {
         "source": [
             "aws.ssm"
         ],
         "detail-type": [
             "Parameter Store Policy Action"
         ],
         "detail": {
             "parameter-name": [
                 "/OncallDuties"
             ],
             "policy-type": [
                 "Expiration"
             ]
         }
     }
     ```

------

1. 選擇**下一步**。

1. 針對 **Target 1** (目標 1 ) 選取目標類型及資源。例如，如果您選擇 **SNS topic** (SNS 主題)，請選取 **Topic** (主題)。如果選取 **CodePipeline**，請在 **Pipeline ARN** 輸入管線 ARN。根據需要提供其他設定值。
**提示**  
如果您的規則需要其他目標，請選擇 **Add another target** (新增另一個目標)。

1. 選擇**下一步**。

1. (選用) 為規則輸入一或多個標籤。如需詳細資訊，請參閱《Amazon EventBridge 使用者指南》**中的 [Amazon EventBridge 標籤](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-tagging.html)。

1. 選擇**下一步**。

1. 選擇**建立規則**。

**詳細資訊**  
+ [使用參數標籤以在環境中輕鬆地更新組態](https://aws.amazon.com/blogs/mt/use-parameter-labels-for-easy-configuration-update-across-environments/)
+ [《Amazon EventBridge 使用者指南》中的教學課程：使用 EventBridge 將事件轉送至 AWS Systems Manager  Run Command](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ec2-run-command.html) * EventBridge *
+ [《Amazon EventBridge 使用者指南》中的教學課程：將 AWS Systems Manager 自動化設定為 EventBridge 目標](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ssm-automation-as-target.html) * EventBridge *