

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

# 開啟 AWS Config 規則的主動評估
<a name="evaluate-config_turn-on-proactive-rules"></a>

您可以使用 AWS Config 主控台或 AWS SDKs來開啟主動評估規則。如需支援主動評估的資源類型和受管規則清單，請參閱[規則的元件 \| 評估模式](https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_components.html#evaluate-config_use-managed-rules-proactive-detective)。

**Topics**
+ [使用主控台](#evaluate-config_turn-on-proactive-rules-console)
+ [使用 AWS SDKs](#evaluate-config_turn-on-proactive-rules-cli)

## 開啟主動評估 （主控台）
<a name="evaluate-config_turn-on-proactive-rules-console"></a>

**規則** 頁面會在表格中顯示您的規則和其目前的合規結果。每個規則的結果都是**評估...**，直到 AWS Config 完成針對規則評估您的資源為止。您可以使用重新整理按鈕來更新結果。

評估 AWS Config 完成後，您可以看到合規或不合規的規則和資源類型。如需詳細資訊，請參閱[使用 檢視 AWS 資源的合規資訊和評估結果 AWS Config](evaluate-config_view-compliance.md)。

**注意**  
AWS Config 只會評估正在記錄的資源類型。例如，如果您新增**啟用 cloudtrail 的**規則，但未記錄 CloudTrail 追蹤資源類型，則 AWS Config 無法評估您帳戶中的追蹤是否合規。如需詳細資訊，請參閱[使用 錄製 AWS 資源 AWS Config考量事項](select-resources.md)。

### 開啟主動評估
<a name="turn-on-proactive-rules-console"></a>

您可以使用*主動評估*，在部署資源之前對其進行評估。這可讓您評估一組資源屬性是否是 AWS COMPLIANT 或 NON\_COMPLIANT，前提是您在區域中的帳戶中擁有一組主動規則。

[資源類型結構描述](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html)會說明資源的屬性。您可以在 AWS CloudFormation 登錄檔中的「*AWS 公有擴充*功能」中找到資源類型結構描述，或使用下列 CLI 命令：

```
aws cloudformation describe-type --type-name "AWS::S3::Bucket" --type {{RESOURCE}}
```

如需詳細資訊，請參閱 AWS CloudFormation 《 使用者指南》中的[透過 CloudFormation 登錄檔管理擴充](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html#registry-view)功能，以及[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。

**注意**  
主動規則不會修復標記為「NON\_COMPLIANT」的資源，也不會防止部署這些資源。

**開啟主動評估**

1. 登入 AWS 管理主控台 ，並在 https：//[https://console.aws.amazon.com/config/home](https://console.aws.amazon.com/config/home) 開啟 AWS Config 主控台。

1. 在 AWS 管理主控台 選單中，確認區域選擇器已設定為支援 AWS Config 規則的區域。如需受支援 AWS 區域的清單，請參閱《*Amazon Web Services 一般參考*》中的 [AWS Config 區域與端點](https://docs.aws.amazon.com/general/latest/gr/rande.html#awsconfig_region)。

1. 在左側導覽中，選擇 **規則**。如需支援主動評估的受管規則清單，請參閱[依評估模式的 AWS Config 受管規則清單](https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-evaluation-mode.html)。

1. 選擇規則，然後針對您要更新的規則選擇 **編輯規則**。

1. 針對 **評估模式**，請選擇 **開啟主動評估**，這可讓您在部署資源之前，對資源的組態設定執行評估。

1. 選擇**儲存**。

開啟主動評估後，您可以使用 [StartResourceEvaluation](https://docs.aws.amazon.com/config/latest/APIReference/API_StartResourceEvaluation.html) API 和 [GetResourceEvaluationSummary](https://docs.aws.amazon.com/config/latest/APIReference/API_GetResourceEvaluationSummary.html) API 來檢查您在這些命令中指定的資源是否會被您區域中帳戶中的主動規則標記為「NON\_COMPLIANT」。

例如，從 StartResourceEvaluation API 開始：

```
aws configservice start-resource-evaluation --evaluation-mode PROACTIVE
                --resource-details '{"ResourceId":"{{MY_RESOURCE_ID}}",
                                     "ResourceType":"{{AWS::RESOURCE::TYPE}}",
                                     "ResourceConfiguration":"{{RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA}}",
                                     "ResourceConfigurationSchemaType":"CFN_RESOURCE_SCHEMA"}'
```

您應該會在輸出中收到 `ResourceEvaluationId`：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID"
}
```

然後，請使用 `ResourceEvaluationId` 與 GetResourceEvaluationSummary API 來檢查評估結果：

```
aws configservice get-resource-evaluation-summary
    --resource-evaluation-id {{MY_RESOURCE_EVALUATION_ID}}
```

您應該會收到類似下列的輸出：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID",
    "EvaluationMode": "PROACTIVE",
    "EvaluationStatus": {
        "Status": "SUCCEEDED"
    },
    "EvaluationStartTimestamp": "2022-11-15T19:13:46.029000+00:00",
    "Compliance": "COMPLIANT",
    "ResourceDetails": {
        "ResourceId": "MY_RESOURCE_ID",
        "ResourceType": "AWS::RESOURCE::TYPE",
        "ResourceConfiguration": "RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA"
    }
}
```

若要查看評估結果的其他資訊，例如哪個規則將資源標記為「NON\_COMPLIANT」，請使用 [GetComplianceDetailsByResource](https://docs.aws.amazon.com/config/latest/APIReference/API_GetComplianceDetailsByResource.html) API。

## 開啟主動評估AWS SDKs)
<a name="evaluate-config_turn-on-proactive-rules-cli"></a>

### 開啟主動評估 (AWS CLI)
<a name="turn-on-proactive-rules-cli"></a>

您可以使用*主動評估*，在部署資源之前對其進行評估。這可讓您評估一組資源屬性是否是 AWS COMPLIANT 或 NON\_COMPLIANT，前提是您在區域中的帳戶中擁有一組主動規則。

[資源類型結構描述](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html)會說明資源的屬性。您可以在 AWS CloudFormation 登錄檔中的「*AWS 公有擴充*功能」中找到資源類型結構描述，或使用下列 CLI 命令：

```
aws cloudformation describe-type --type-name "AWS::S3::Bucket" --type {{RESOURCE}}
```

如需詳細資訊，請參閱 AWS CloudFormation 《 使用者指南》中的[透過 CloudFormation 登錄檔管理擴充](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html#registry-view)功能，以及[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。

**注意**  
主動規則不會修復標記為「NON\_COMPLIANT」的資源，也不會防止部署這些資源。

**開啟主動評估**

使用 [https://docs.aws.amazon.com/cli/latest/reference/configservice/put-config-rule.html](https://docs.aws.amazon.com/cli/latest/reference/configservice/put-config-rule.html) 命令並啟用 `EvaluationModes` 的 `PROACTIVE`。

開啟主動評估後，您可以使用 [start-resource-evaluation](https://docs.aws.amazon.com/cli/latest/reference/configservice/start-resource-evaluation.html) CLI 命令和 [get-resource-evaluation-summary](https://docs.aws.amazon.com/cli/latest/reference/configservice/get-resource-evaluation-summary.html) CLI 命令，檢查您在這些命令中指定的資源是否會被您區域中帳戶中的主動規則標記為「NON\_COMPLIANT」。

例如，從 **start-resource-evaluation** 命令開始：

```
aws configservice start-resource-evaluation --evaluation-mode PROACTIVE
                --resource-details '{"ResourceId":"{{MY_RESOURCE_ID}}",
                                     "ResourceType":"{{AWS::RESOURCE::TYPE}}",
                                     "ResourceConfiguration":"{{RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA}}",
                                     "ResourceConfigurationSchemaType":"CFN_RESOURCE_SCHEMA"}'
```

您應該會在輸出中收到 `ResourceEvaluationId`：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID"
}
```

然後，請使用 `ResourceEvaluationId` 與 **get-resource-evaluation-summary** 來檢查評估結果：

```
aws configservice get-resource-evaluation-summary
    --resource-evaluation-id {{MY_RESOURCE_EVALUATION_ID}}
```

您應該會收到類似下列的輸出：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID",
    "EvaluationMode": "PROACTIVE",
    "EvaluationStatus": {
        "Status": "SUCCEEDED"
    },
    "EvaluationStartTimestamp": "2022-11-15T19:13:46.029000+00:00",
    "Compliance": "COMPLIANT",
    "ResourceDetails": {
        "ResourceId": "MY_RESOURCE_ID",
        "ResourceType": "AWS::RESOURCE::TYPE",
        "ResourceConfiguration": "RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA"
    }
}
```

若要查看評估結果的其他資訊，例如哪個規則將資源標記為「NON\_COMPLIANT」，請使用 [get-compliance-details-by-resource](https://docs.aws.amazon.com/cli/latest/reference/configservice/get-compliance-details-by-resource.html) CLI 命令。

**注意**  
如需支援主動評估的受管規則清單，請參閱[依評估模式的 AWS Config 受管規則清單](https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-evaluation-mode.html)。

### 開啟主動評估 (API)
<a name="turn-on-proactive-rules-api"></a>

您可以使用*主動評估*，在部署資源之前對其進行評估。這可讓您評估一組資源屬性是否是 AWS COMPLIANT 或 NON\_COMPLIANT，前提是您在區域中的帳戶中擁有一組主動規則。

[資源類型結構描述](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-type-schema.html)會說明資源的屬性。您可以在 AWS CloudFormation 登錄檔中的「*AWS 公有擴充*功能」中找到資源類型結構描述，或使用下列 CLI 命令：

```
aws cloudformation describe-type --type-name "AWS::S3::Bucket" --type {{RESOURCE}}
```

如需詳細資訊，請參閱 AWS CloudFormation 《 使用者指南》中的[透過 CloudFormation 登錄檔管理擴充](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html#registry-view)功能，以及[AWS 資源和屬性類型參考](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)。

**注意**  
主動規則不會修復標記為「NON\_COMPLIANT」的資源，也不會防止部署這些資源。

**開啟規則的主動評估**

使用 [PutConfigRule](https://docs.aws.amazon.com/config/latest/APIReference/API_PutConfigRule.html) 動作並啟用 `EvaluationModes` 的 `PROACTIVE`。

開啟主動評估後，您可以使用 [StartResourceEvaluation](https://docs.aws.amazon.com/config/latest/APIReference/API_StartResourceEvaluation.html) API 和 [GetResourceEvaluationSummary](https://docs.aws.amazon.com/config/latest/APIReference/API_GetResourceEvaluationSummary.html) API 來檢查您在這些命令中指定的資源是否會被您區域中帳戶中的主動規則標記為「NON\_COMPLIANT」。例如，從 StartResourceEvaluation API 開始：

```
aws configservice start-resource-evaluation --evaluation-mode PROACTIVE
                --resource-details '{"ResourceId":"{{MY_RESOURCE_ID}}",
                                     "ResourceType":"{{AWS::RESOURCE::TYPE}}",
                                     "ResourceConfiguration":"{{RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA}}",
                                     "ResourceConfigurationSchemaType":"CFN_RESOURCE_SCHEMA"}'
```

您應該會在輸出中收到 `ResourceEvaluationId`：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID"
}
```

然後，請使用 `ResourceEvaluationId` 與 GetResourceEvaluationSummary API 來檢查評估結果：

```
aws configservice get-resource-evaluation-summary
    --resource-evaluation-id {{MY_RESOURCE_EVALUATION_ID}}
```

您應該會收到類似下列的輸出：

```
{
    "ResourceEvaluationId": "MY_RESOURCE_EVALUATION_ID",
    "EvaluationMode": "PROACTIVE",
    "EvaluationStatus": {
        "Status": "SUCCEEDED"
    },
    "EvaluationStartTimestamp": "2022-11-15T19:13:46.029000+00:00",
    "Compliance": "COMPLIANT",
    "ResourceDetails": {
        "ResourceId": "MY_RESOURCE_ID",
        "ResourceType": "AWS::RESOURCE::TYPE",
        "ResourceConfiguration": "RESOURCE_DEFINITION_AS_PER_THE_RESOURCE_CONFIGURATION_SCHEMA"
    }
}
```

若要查看評估結果的其他資訊，例如哪個規則將資源標記為「NON\_COMPLIANT」，請使用 [GetComplianceDetailsByResource](https://docs.aws.amazon.com/config/latest/APIReference/API_GetComplianceDetailsByResource.html) API。

**注意**  
如需支援主動評估的受管規則清單，請參閱[依評估模式的 AWS Config 受管規則清單](https://docs.aws.amazon.com/config/latest/developerguide/managed-rules-by-evaluation-mode.html)。