跳至內容

為什麼我在建立 AWS Config 組態記錄器時收到 MaxNumberOfConfigurationRecordersExceededException 錯誤?

2 分的閱讀內容
0

當我建立 AWS Config 組態記錄器時,收到 MaxNumberOfConfigurationRecordersExceededException 錯誤。

簡短描述

AWS Config 使用組態記錄器記錄資源組態中的變更。AWS Config 只允許帳戶中的每個 AWS 區域有一個組態記錄器。MaxNumberOfConfigurationRecordersExceededException 錯誤表示您無法建立新的組態記錄器,因為區域的帳戶中已有一個組態記錄器。無論您使用的是 AWS Config 主控台、AWS Command Line Interface (AWS CLI) 還是 AWS CloudFormation 來建立記錄器,都會發生該錯誤。

解決方法

**注意:**如果您在執行 AWS CLI 命令時收到錯誤,請參閱對 AWS CLI 錯誤進行疑難排解。此外,請確定您使用的是最新的 AWS CLI 版本。

若要解決 MaxNumberOfConfigurationRecordersExceededException 錯誤,並建立新的組態記錄器,您必須識別並刪除現有的組態記錄器。

**注意:**您無法從主控台刪除組態記錄器。您必須以程式設計方式執行刪除。

首先,確認已設定正確的 AWS Identity and Access Management (IAM) 權限以執行所需的命令。然後,您可以使用 AWS CLI 或 CloudFormation 來識別和刪除現有的組態記錄器。

IAM 權限

若要描述和刪除組態記錄器,請新增下列 IAM 權限:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "config:DescribeConfigurationRecorders",
                "config:DeleteConfigurationRecorder"
            ],
            "Resource": "*"
        }
    ]
}

若要啟動和停止組態記錄器,請新增下列 IAM 權限:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "config:PutConfigurationRecorder",
                "iam:PassRole",
                "config:DescribeConfigurationRecorders",
                "config:StopConfigurationRecorder",
                "config:StartConfigurationRecorder",
                "config:DeleteConfigurationRecorder"
            ],
            "Resource": "*"
        }
    ]
}

對於 AWS CLI,請識別和刪除組態記錄器

請完成下列任務。

識別現有的組態記錄器名稱

若要識別特定區域中現有的組態記錄器,請執行 describe-configuration-recorders 命令:

$aws configservice describe-configuration-recorders --region RegionID

**注意:**將 RegionID 替換為您的區域。

檢閱輸出結果。現有的組態記錄器名稱會列在輸出中的名稱旁邊。

刪除現有的組態記錄器

若要刪除現有的組態記錄器,請執行 delete-configuration-recorder 命令:

$aws configservice delete-configuration-recorder --configuration-recorder-name RecorderName --region RegionID

**注意:**將 RecorderName 替換為您組態錄器的名稱,將 RegionID 替換為您的區域 ID。成功刪除記錄器後,delete-configuration-recorder 命令不會傳回輸出。

使用 API 呼叫來啟動和停止記錄器

若要啟動組態記錄器,請執行下列命令:

$aws configservice start-configuration-recorder --configuration-recorder-name RecorderName

**注意:**將 RecorderName 替換為您組態記錄器的名稱。

若要停止組態記錄器,請執行下列命令:

$aws configservice stop-configuration-recorder --configuration-recorder-name RecorderName

**注意:**將 RecorderName 替換為您組態記錄器的名稱。

對於 CloudFormation,請識別並刪除組態記錄器

如果您使用 CloudFormation StackSet 範本來開啟 AWS Config,請完成下列任務來識別和刪除組態記錄器。

若要編寫程式碼邏輯來識別和刪除組態記錄器,請使用 AWS Lambda 支援的自訂資源執行下列操作:

刪除組態記錄器之後,您可以使用自訂資源的 cfn-response 模組來建立新的組態記錄器。然後,您可以執行 StartConfigurationRecorder API 來啟動記錄器。

相關資訊

使用 Python、AWS Lambda 和 crhelper 建立 CloudFormation 自訂資源

AWS 官方已更新 1 年前