當我的 ACM 匯入憑證即將到期時,該如何收到通知?
我已匯入 AWS Certificate Manager (ACM) 憑證,並希望在憑證到期前收到提醒以重新匯入該憑證。
簡短說明
若要在您的憑證即將到期時收到通知,請使用以下其中一種方法:
- 設定 ACM Certificate Approaching Expiration 事件。
- 建立自訂 Amazon EventBridge 規則和 AWS Config 規則。
- 建立 Amazon CloudWatch 警示。
根據預設,ACM Certificate Approaching Expiration 事件會在事件到期前 45 天傳送通知。您可以變更天數,但不可超過 45 天。若要設定事件到期前 45 天以上的通知,請使用自訂 EventBridge 規則或 CloudWatch 警示。
解決方法
在 EventBridge 中設定 ACM Certificate Approaching Expiration 事件
**先決條件:**如果您沒有 Amazon Simple Notification Service (Amazon SNS) 主題,請建立主題。
請完成以下步驟:
- 開啟 EventBridge console (EventBridge 主控台)。
- 在導覽窗格中,選擇 Rules (規則),然後選擇 Create rule (建立規則)。
- 為您的規則輸入 Name (名稱)。
**注意:**您必須為位於相同 AWS Region 且在相同事件匯流排上的規則,指定唯一名稱。 - 在 Event bus (事件匯流排),選取事件匯流排。若要讓規則與來自您 AWS 帳戶的事件相符,請選取 AWS default event bus (AWS 預設事件匯流排),使事件傳送至您帳戶的預設事件匯流排。
- 在 Rule type (規則類型),選擇 Rule with an event pattern (具有事件模式的規則),然後選擇 Next (下一步)。
- 在 Event source (事件來源),選擇 AWS events or EventBridge partner events (AWS 事件或 EventBridge 合作夥伴事件)。
- 在 Creation method (建立方法),選擇 Use pattern form option (使用模式表單選項)。
- 在 Event pattern (事件模式) 區段中,完成以下步驟:
在 Event source (事件來源),選擇 AWS Services (AWS 服務)。
在 AWS service (AWS 服務),選擇 Certificate Manager。
在 Event type (事件類型),選擇 ACM Certificate Approaching Expiration (ACM 憑證即將到期)。 - 選擇 Next (下一步)。
- 在 Target types (目標類型),選擇 AWS Service (AWS 服務)。
- 在 Select a target (選取目標),選擇 SNS topic (SNS 主題),然後選取 Amazon SNS 主題。
- 選擇 Next (下一步)。
- (選用) 新增標籤。
- 選擇 Next (下一步)。
- 檢閱規則詳細資訊,然後選擇 Create rule (建立規則)。
建立規則後,您可以變更接收到期通知的日期。在 PutAccountConfiguration ACM API 操作中,為 DaysBeforeExpiry 輸入 1 至 45 之間的值。
建立自訂 EventBridge 規則和 AWS Config 規則
**先決條件:**如果您沒有 Amazon SNS 主題,請建立主題。
使用自訂事件模式搭配 EventBridge 規則,以符合 acm-certificate-expiration-check AWS Config 受管規則。然後,將回應路由至 Amazon SNS 主題。 Amazon SNS 主題必須與您的 AWS Config 服務位於相同 AWS Region。
**注意:**使用 AWS Config 時,會產生費用。如需更多資訊,請參閱 AWS Config 定價。
建立 EventBridge 規則
請完成以下步驟:
-
開啟 EventBridge console (EventBridge 主控台)。
-
選擇 Rules (規則),然後選擇 Create rule (建立規則)。
-
在 Name (名稱) 中,為您的規則輸入名稱。
-
在 Rule type (規則類型) 中,選擇 Rule with and event pattern (具有事件模式的規則),然後選擇 Next (下一步)。
-
在 Event source (事件來源),選擇 AWS events or EventBridge partner events (AWS 事件或 EventBridge 合作夥伴事件)。
-
在 Event pattern (事件模式) 中,選擇 Custom patterns (JSON editor) (自訂模式 (JSON 編輯器))。
-
在 Event pattern (事件模式) 預覽窗格中,輸入以下事件模式:
{ "source": [ "aws.config" ], "detail-type": [ "Config Rules Compliance Change" ], "detail": { "messageType": [ "ComplianceChangeNotification" ], "configRuleName": [ "acm-certificate-expiration-check" ], "resourceType": [ "AWS::ACM::Certificate" ], "newEvaluationResult": { "complianceType": [ "NON_COMPLIANT" ] } } } -
選擇 Next (下一步)。
-
在 Select a target (選取目標) 中,選擇 SNS topic (SNS 主題)。
-
在 Topic (主題) 中,選取您的 SNS 主題。
-
在 Configure target input (設定目標輸入) 下拉式清單中,選擇 Input transformer (輸入轉換器)。
-
選擇 Configure input transformer (設定輸入轉換器)。
-
在 Input path (輸入路徑) 文字方塊中,輸入以下路徑:
{ "awsRegion": "$.detail.awsRegion", "resourceId": "$.detail.resourceId", "awsAccountId": "$.detail.awsAccountId", "compliance": "$.detail.newEvaluationResult.complianceType", "rule": "$.detail.configRuleName", "time": "$.detail.newEvaluationResult.resultRecordedTime", "resourceType": "$.detail.resourceType" }
- 在 Template (範本) 文字方塊中,輸入以下範本:
"On example_time AWS Config rule example_rule evaluated the example_resourceType with Id example_resourceId in the account example_awsAccountId region example_awsRegion as example_compliancetype.""For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=awsRegion#/timeline/resourceType/resourceId/configuration."
**注意:**請將範例值替換為您的值。 選擇 Confirm (確認),然後選擇 Next (下一步)。 再次選擇 Next (下一步),然後選擇 Create rule (建立規則)。
如果 ACM 啟用事件類型,那麼您會收到 SNS 電子郵件通知。
建立 AWS Config 規則
若要建立 AWS Config 規則,請完成以下步驟:
- 開啟 AWS Config console (AWS Config 主控台)。
- 在導覽窗格中,選擇 Rules (規則),然後選擇 Add rule (新增規則)。
- 在 Select rule type (選取規則類型) 中,選擇 Add AWS managed rule (新增 AWS 受管規則)。
- 在 AWS Managed Rules (AWS 受管規則) 中,選擇 acm-certificate-expiration-check,然後選擇 Next (下一步)。
- 在 Parameters (參數) 頁面上,於 Value (值) 中,在 daysToExpiration 索引鍵輸入您希望規則調用的天數。
**注意:**如果憑證在您輸入的天數內接近到期日,則 acm-certificate-expiration-check 規則會將該規則識別為 NON_COMPLIANT。 - 選擇 Next (下一步),然後選擇 Add rule (新增規則)。
根據靜態閾值建立 CloudWatch 警示
請完成以下步驟:
- 開啟 CloudWatch console (CloudWatch 主控台)。
- 在導覽窗格中,選擇 Alarms (警示),然後選擇 All alarms (所有警示)。
- 選擇 Create alarm (建立警示),然後選擇 Select metric (選取指標)。
- 選擇 Certificate Manager,然後選擇 Certificate Metrics (憑證指標)。
- 在 Metrics (指標) 頁面上,選取指標,然後選擇 Select metric (選取指標)。
- 在 Specify metric and conditions (指定指標與條件) 頁面上,於 Statistic (統計) 中選擇 Minimum (最小值)。
- 在 Period (期間) 中,選擇 1 day (1 天)。
- 在 Whenever DaysToExpiry is... (當 DaysToExpiry 為...) 中,選擇 Lower/Equal (小於/等於),然後將 than... (值...) 設為您希望在到期前執行警示的天數。
- 選擇 Next (下一步)。
- 在 Notification (通知) 中,選擇 In alarm (處於警示狀態時)。
- 在 Send a notification to the following SNS topic (將通知傳送至以下 SNS 主題) 中,選擇 Select an existing SNS topic (選取現有 SNS 主題) 或 Create new topic (建立新主題),然後選擇 Next (下一步)。
- 輸入警示名稱,選擇 Next (下一步)。
- 選擇 Create alarm (建立警示)。
如需更多資訊,請參閱 根據靜態閾值建立 CloudWatch 警示。
相關資訊
開始使用 AWS Certificate Manager 憑證
- 語言
- 中文 (繁體)

相關內容
- 已提問 3 年前
- 已提問 1 年前
AWS 官方已更新 9 個月前