

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

# 編輯通知規則
<a name="notification-rule-edit"></a>

您可以編輯通知規則以變更其名稱、傳送通知所針對的事件、詳細資訊類型，或通知傳送到的一或多個目標。您可以使用開發人員工具主控台或 AWS CLI 編輯通知規則。<a name="notification-rule-edit-console"></a>

# 編輯通知規則 (主控台)
<a name="notification-rule-edit-console"></a>

1. 開啟位於 https：//[https://console.aws.amazon.com/codesuite/settings/notifications](https://console.aws.amazon.com/codesuite/settings/notifications/) 的 AWS 開發人員工具主控台。

1. 在導覽列中，展開 **Settings (設定)**，然後選擇 **Notification rules (通知規則)**。

1. 在**通知規則**中，檢閱 AWS 區域 您目前登入之 中為 AWS 帳戶中資源設定的規則。使用選擇器變更 AWS 區域。

1. 從清單中選擇規則，然後選擇 **Edit (編輯)**。進行變更，然後選擇 **Submit (提交)**。<a name="notification-rule-edit-cli"></a>

# 編輯通知規則 (AWS CLI)
<a name="notification-rule-edit-cli"></a>

1. 在終端機或命令提示字元中，執行 [describe-notification-rule 命令](notification-rule-view.md#notification-rule-view-details-cli)，以檢視通知規則的結構。

1. 執行 **update-notification rule** 命令來產生 JSON 基本結構，然後儲存到檔案。

   ```
   aws codestar-notifications update-notification-rule --generate-cli-skeleton > {{update.json}}
   ```

   您可以將檔案命名為任何您想要的名稱。在此範例中，檔案為 {{update.json}}。

1. 在純文字編輯器中開啟 JSON 檔案，並對規則進行變更。

   下列範例顯示 ID **MyNotificationRule** 為 {{123456789012}} AWS 之帳戶中名為 {{MyDemoRepo}} 之儲存庫的通知規則。建立分支和標籤時，通知會傳送到名為 {{MyNotificationTopic}} 的 Amazon SNS 主題。規則名稱變更為 {{MyNewNotificationRule}}。

   ```
   {
       "Name": "{{MyNewNotificationRule}}",
       "EventTypeIds": [
           "codecommit-repository-branches-and-tags-created"
       ],
       "Resource": "arn:aws:codecommit:{{us-east-1}}:{{123456789012}}:{{MyDemoRepo}}",
       "Targets": [
           {
               "TargetType": "SNS",
               "TargetAddress": "arn:aws:sns:{{us-east-1}}:{{123456789012}}:{{MyNotificationTopic}}"
           }
       ],
       "Status": "ENABLED",
       "DetailType": "FULL"
   }
   ```

   儲存檔案。

1. 在終端機或命令列中，再次執行 **update-notification-rule** 命令，使用您剛編輯的檔案更新通知規則。

   ```
   aws codestar-notifications update-notification-rule --cli-input-json  file://{{update}}.json
   ```

1. 如果成功，此命令會傳回通知規則的 Amazon Resource Name (ARN)，如下所示。

   ```
   {
       "Arn": "arn:aws:codestar-notifications:{{us-east-1}}:{{123456789012}}:notificationrule/dc82df7a-EXAMPLE"
   }
   ```<a name="notification-rule-remove-tag-cli"></a>

# 從通知規則移除標籤 (AWS CLI)
<a name="notification-rule-remove-tag-cli"></a>

1. 在終端機或命令提示字元中，執行 **untag-resource** 命令。例如，以下命令會移除包含 {{Team}} 名稱的標籤。

   ```
   aws codestar-notifications untag-resource --arn arn:aws:codestar-notifications:us-east-1:123456789012:notificationrule/fe1efd35-EXAMPLE --tag-keys Team
   ```

1. 若成功，此命令不會傳回任何內容。

## 另請參閱
<a name="notification-rule-edit-also"></a>
+ [新增或移除通知規則的目標](notification-target-change-rule.md)
+ [啟用或停用通知規則的通知](notification-rule-enable-disable.md)
+ [事件](concepts.md#events)