查看配置合规性 - Amazon Config
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

查看配置合规性

重要

要准确报告合规性状态,必须记录 AWS::Config::ResourceCompliance 资源类型。有关更多信息,请参阅选择 Amazon Config 记录哪些资源

您可以使用 Amazon Config 控制台 Amazon CLI、或 Amazon Config API 来查看您的规则和资源的合规性状态。

查看合规性(控制台)

  1. 登录 Amazon Web Services Management Console 并打开 Amazon Config 控制台,网址为 https://console.aws.amazon.com/config/

  2. 在 Amazon Web Services Management Console 菜单中,确认区域选择器设置为支持 Amazon Config 规则的区域。有关支持的区域的列表,请参阅《Amazon Web Services 一般参考》中的 Amazon Config 区域和终端节点

  3. 在导航窗格中,选择资源。在“资源”清单页面上,您可以按资源类别、资源类型和合规性状态进行筛选。根据需要选择包括已删除的资源。该表显示了资源类型的资源标识符和该资源的资源合规性状态。资源标识符可以是资源 ID,也可以是资源名称。

  4. 从资源标识符列中选择资源。

  5. 选择资源时间表按钮。您可以按配置事件、合规性事件或 CloudTrail 事件进行筛选。

    注意

    或者,在“资源”清单页面上,您可以直接选择资源名称。要从资源详细信息页面访问资源时间表,请选择资源时间表按钮。

此外,您还可以在 Resource inventory 页面查找您的资源,以查看其合规性。有关更多信息,请参阅查找由以下人员发现的资源 Amazon Config

查看合规性 (Amazon CLI)

要查看合规性,请使用以下任一 CLI 命令:

To see the compliance state of each of your rules

要查看您的每个规则的合规性状态,请使用 describe-compliance-by-config-rule 命令,如以下示例所示:

$ aws configservice describe-compliance-by-config-rule { "ComplianceByConfigRules": [ { "Compliance": { "ComplianceContributorCount": { "CappedCount": 2, "CapExceeded": false }, "ComplianceType": "NON_COMPLIANT" }, "ConfigRuleName": "instances-in-vpc" }, { "Compliance": { "ComplianceType": "COMPLIANT" }, "ConfigRuleName": "restricted-common-ports" }, ...

对于合规性类型为 NON_COMPLIANT 的每个规则, Amazon Config 将为 CappedCount 参数返回不合规资源的数量。

To see the compliance state of each resource that Amazon Config evaluates for a specific rule

要查看针对特定规则 Amazon Config 评估的每个资源的合规性状态,请使用get-compliance-details-by-config-rule命令,如以下示例所示:

$ aws configservice get-compliance-details-by-config-rule --config-rule-name ConfigRuleName{ "EvaluationResults": [ { "EvaluationResultIdentifier": { "OrderingTimestamp": 1443610576.349, "EvaluationResultQualifier": { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-nnnnnnnn", "ConfigRuleName": "ConfigRuleName" } }, "ResultRecordedTime": 1443751424.969, "ConfigRuleInvokedTime": 1443751421.208, "ComplianceType": "COMPLIANT" }, { "EvaluationResultIdentifier": { "OrderingTimestamp": 1443610576.349, "EvaluationResultQualifier": { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-nnnnnnnn", "ConfigRuleName": "ConfigRuleName" } }, "ResultRecordedTime": 1443751425.083, "ConfigRuleInvokedTime": 1443751421.301, "ComplianceType": "NON_COMPLIANT" }, ...
To see the compliance state for each Amazon resource of a specific type

要查看特定类型的每种 Amazon 资源的合规性状态,请使用describe-compliance-by-resource命令,如以下示例所示:

$ aws configservice describe-compliance-by-resource --resource-type AWS::EC2::Instance { "ComplianceByResources": [ { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-nnnnnnnn", "Compliance": { "ComplianceContributorCount": { "CappedCount": 1, "CapExceeded": false }, "ComplianceType": "NON_COMPLIANT" } }, { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-nnnnnnnn", "Compliance": { "ComplianceType": "COMPLIANT" } }, ...
To see the compliance details of an individual Amazon resource

要查看单个 Amazon 资源的合规性详细信息,请使用get-compliance-details-by-resource命令。

$ aws configservice get-compliance-details-by-resource --resource-type AWS::EC2::Instance --resource-id i-nnnnnnnn { "EvaluationResults": [ { "EvaluationResultIdentifier": { "OrderingTimestamp": 1443610576.349, "EvaluationResultQualifier": { "ResourceType": "AWS::EC2::Instance", "ResourceId": "i-nnnnnnnn", "ConfigRuleName": "instances-in-vpc" } }, "ResultRecordedTime": 1443751425.083, "ConfigRuleInvokedTime": 1443751421.301, "ComplianceType": "NON_COMPLIANT" } ] }

查看合规性 (API)

要查看合规性,请使用以下任一 API 操作: