當我的 ACM 匯入憑證即將到期時,如何收到通知?

3 分的閱讀內容
0

我匯入了 AWS Certificate Manager (ACM) 憑證,並且希望在憑證到期前提醒重新匯入憑證。

簡短描述

ACM 不會為匯入的憑證提供受管續約。若要續約匯入的憑證,請先向憑證簽發者請求新憑證。然後,手動將憑證重新匯入 ACM

若要收到您憑證即將到期的通知,請使用下列其中一種方法:

  • 使用 Amazon EventBridge 中的 ACM API 設定 ACM 憑證即將到期事件。
  • 建立自訂 EventBridge 規則,在憑證接近到期日時接收電子郵件通知。
  • 使用 AWS Config 檢查是否有接近到期日的憑證。

如果您將 AWS Config 用於此解決方案,請注意以下事項:

  • 在設定 AWS Config 規則之前,請先建立 Amazon Simple Notification Service (Amazon SNS) 主題和 EventBridge 規則。這可確保所有不合規的憑證均會在到期日之前叫用通知。
  • 啟用 AWS Config 會根據用量而產生額外的費用。如需詳細資訊,請參閱 AWS Config 定價

解決方案

在 EventBridge 中設定「ACM 憑證即將到期」事件

ACM 會透過 Amazon CloudWatch 針對接近到期日的事件傳送通知。依據預設,ACM 憑證即將到期事件會在事件到期前 45 天傳送通知。若要設定此通知的時間,請先將此事件新增為 EventBridge 中的規則:

1.    開啟 Amazon EventBridge 主控台

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

3.    輸入規則的 Name (名稱)。Description (描述) 欄位是選擇性的。

**備註:**您必須唯一命名位於相同 AWS 區域和相同事件匯流排上的規則。

4.    對於 Event bus (事件匯流排),請選擇要與此規則產生關聯的事件匯流排。若要將此規則與來自您帳戶的事件相符,請選取 AWS default event bus (AWS 預設事件匯流排)。在此情況下,當您帳戶中的 AWS 服務發生事件時,它一律會轉至您帳戶的預設事件匯流排。

5.    對於 Rule type (規則類型) 中,選取 Rule with and event pattern (包含事件模式的規則),然後選擇 Next (下一步)。

6.    對於 Event source (事件來源),請選擇 AWS events or EventBridge partner events (AWS 事件或 EventBridge 合作夥伴事件)。

7.    對於 Creation method (建立方法),請選取 Use pattern form (使用樣式形式) 選項。

8.    在 Event pattern (事件模式) 區段中,如下所述完成下列欄位:

對於 Event source (事件來源),請選擇 AWS services (AWS 服務)。

對於 AWS service (AWS 服務),請選擇 Certificate Manager (憑證管理員)。

對於 Event type (事件類型),選擇 ACM Certificate Approaching Expiration (ACM 憑證即將到期)。

9.    選擇 Next (下一步)。

10.    對於 Target types (目標類型),選擇 AWS service ( AWS 服務)。

11.   對於 Select a target (選取目標),選取 SNS topic (SNS 主題),然後選取您要設定到期通知的主題。

12.   選擇 Next (下一步)。

(選用) 新增標籤。

13.    選擇 Next (下一步)。

14.   檢閱規則的詳細資料,然後選擇 Create rule (建立規則)。

建立此規則後,您可以變更到期通知的時間。在 ACM API 的 PutAccountConfiguration 動作中,為 DaysBeforeExpiry 輸入 1-45 的值。如需詳細資訊,請參閱 ACM 憑證即將到期事件

如果您想要在事件到期前 45 天以上設定通知,請使用下列替代方法。

建立自訂 EventBridge 規則

搭配 EventBridge 規則使用自訂事件模式,以符合 AWS Config 受管規則 acm-certificate-expiration-check。然後,將回應路由傳送至 Amazon Simple Notification Service 主題。

1.    如果您未建立 Amazon SNS 主題,請依照 Amazon SNS 入門的指示來操作。

**備註:**Amazon SNS 主題必須與您的 AWS Config 服務位於相同 AWS 區域。

2.    開啟 EventBridge 主控台,然後選擇 Rules (規則)。

3.    選擇 Create rule (建立規則)。

4.    在 Name (名稱) 中,輸入您的規則名稱。

5.    在 Rule type (規則類型) 中,選取 Rule with and event pattern (包含事件模式的規則),然後選擇 Next (下一步)。

6.    在 Event source (事件來源) 中,請選擇 AWS events or EventBridge partner events (AWS 事件或 EventBridge 合作夥伴事件)。

7.    在 Event pattern (事件模式) 中,選擇 Custom patterns (JSON editor) (自訂模式 (JSON 編輯器))。

8.    在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"
      ]
    }
  }
}

9.    選擇 Next (下一步)。

10.    在 Select a target (選擇目標) 中,選擇 SNS topic (SNS 主題)。

11.   在 Topic (主題) 中,選擇您的 SNS 主題。

12.    在 Configure target input (設定目標輸入) 下拉式清單中,選擇 Input transformer (輸入變壓器)。

13.    選擇 Configure input transformer (設定輸入變壓器)。

14.    在 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"
}

15.    在 Input Template (輸入範本) 文字方塊中,複製並貼上下列範本:

"On <time> AWS Config rule <rule> evaluated the <resourceType> with Id <resourceId> in the account <awsAccountId> region <awsRegion> as <compliance>."

"For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=<awsRegion>#/timeline/<resourceType>/<resourceId>/configuration."

16.    選擇 Confirm (確認)、Next (下一步)、Next (下一步)、Create rule建立規則)。

17.    如果事件類型啟動,您會收到 SNS 電子郵件通知,其中包含填入了來自步驟 14 的內容之自訂欄位,類似下列內容:

"On ExampleTime AWS Config rule ExampleRuleName evaluated the ExampleResourceType with Id ExampleResource_ID in the account ExampleAccount_Id in Region ExampleRegion as ExamplecomplianceType. 

For more details open the AWS Config console at https://console.aws.amazon.com/config/home?region=ExampleRegion#/timeline/ExampleResourceType/ExampleResource_ID/configuration"

建立 AWS Config 規則

1.    開啟 AWS Config 主控台,選擇 Rules (規則),然後選擇 Add rule (新增規則)。

2.    在 Select rule type (選取規則類型) 中,選擇 Add AWS managed rule (新增 AWS 受管規則)。

3.    在 AWS Managed Rules (AWS 受管規則) 中,選擇 acm-certificate-expiration-check,然後選擇 Next (下一步)。

4.    在 Parameters (參數) 中,對於 daysToExpiration 索引鍵,在 Value (值) 中,輸入您希望規則在到期前觸發的天數。

**備註:**對於即將到期的憑證,AWS Config 規則 acm-certificate-expiration-check 會從輸入的天數起即標記為 Noncompliant (不合規)。

5.    選擇 Next (下一步),然後選擇 Add rule (新增規則)。


相關資訊

核發和管理憑證

如何使用 AWS Config 在 AWS 資源不合規時收到通知?

AWS Config 安全最佳實務

AWS 官方
AWS 官方已更新 1 年前
沒有評論