

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

# 登录和监控 AWS Config
<a name="security-logging-and-monitoring"></a>

AWS Config 与 AWS CloudTrail一项服务集成，该服务提供用户、角色或 AWS 服务在中执行的操作的记录 AWS Config。监控是维护 AWS 解决方案的可靠性、可用性和性能的重要组成部分。 AWS Config 

**Topics**
+ [日志记录](log-api-calls.md)
+ [Monitoring](monitoring.md)

# 使用记录 AWS Config API 调用 AWS CloudTrail
<a name="log-api-calls"></a>

CloudTrail 将所有 API 调用捕获 AWS Config 为事件。捕获的调用包括来自 AWS Config 控制台的调用和对 AWS Config API 操作的代码调用。如果您创建了跟踪，则可以允许将 CloudTrail 事件持续传输到 Amazon S3 存储桶，包括的事件 AWS Config。如果您未配置跟踪，您仍然可以在 CloudTrail 控制台的 “事件**历史记录” 中查看最新的事件**。使用收集的信息 CloudTrail，您可以确定向哪个请求发出 AWS Config、发出请求的 IP 地址、谁发出了请求、何时发出请求以及其他详细信息。

要了解更多信息 CloudTrail，请参阅《[AWS CloudTrail 用户指南》](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)。

**Topics**
+ [AWS Config 中的信息 CloudTrail](#service-name-info-in-cloudtrail)
+ [了解 AWS Config 日志文件条目](#understanding-awsconfig-entries)
+ [示例日志文件](#cloudtrail-log-files-for-aws-config)

## AWS Config 中的信息 CloudTrail
<a name="service-name-info-in-cloudtrail"></a>

CloudTrail 在您创建账户 AWS 账户 时已在您的账户上启用。当活动发生在中时 AWS Config，该活动会与其他 AWS 服务 CloudTrail 事件一起记录在**事件历史**记录中。您可以在中查看、搜索和下载最近发生的事件 AWS 账户。有关更多信息，请参阅[使用事件历史记录查看 CloudTrail 事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。

要持续记录您的 AWS 账户事件（包括的事件） AWS Config，请创建跟踪。*跟踪*允许 CloudTrail 将日志文件传输到 Amazon S3 存储桶。默认情况下，在控制台中创建跟踪记录时，此跟踪记录应用于所有 AWS 区域。跟踪记录 AWS 分区中所有区域的事件，并将日志文件传送到您指定的 Amazon S3 存储桶。此外，您可以配置其他 AWS 服务，以进一步分析和处理 CloudTrail 日志中收集的事件数据。有关更多信息，请参阅下列内容：
+ [创建跟踪概述](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 支持的服务和集成](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [配置 Amazon SNS 通知 CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [接收来自多个区域的 CloudTrail 日志文件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html)和[接收来自多个账户的 CloudTrail日志文件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

所有 AWS Config 操作均由《API 参考》记录 CloudTrail 并记录在《[AWS Config API 参考](https://docs.aws.amazon.com/config/latest/APIReference/)》中。例如，对[DeliverConfigSnapshot[DeleteDeliveryChannel](https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteDeliveryChannel.html)](https://docs.aws.amazon.com/config/latest/APIReference/API_DeliverConfigSnapshot.html)、和[DescribeDeliveryChannels](https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html)操作的调用会在 CloudTrail 日志文件中生成条目。

每个事件或日志条目都包含有关生成请求的人员信息。身份信息有助于您确定以下内容：
+ 请求是使用根证书还是 AWS Identity and Access Management (IAM) 用户凭证发出。
+ 请求是使用角色还是联合用户的临时安全凭证发出的。
+ 请求是否由其他 AWS 服务发出。

有关更多信息，请参阅 [CloudTrail userIdentity 元素](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)。

## 了解 AWS Config 日志文件条目
<a name="understanding-awsconfig-entries"></a>

跟踪是一种配置，允许将事件作为日志文件传输到您指定的 Amazon S3 存储桶。 CloudTrail 日志文件包含一个或多个日志条目。事件代表来自任何来源的单个请求，包括有关请求的操作、操作的日期和时间、请求参数等的信息。 CloudTrail 日志文件不是公共 API 调用的有序堆栈跟踪，因此它们不会按任何特定的顺序出现。

## 示例日志文件
<a name="cloudtrail-log-files-for-aws-config"></a>

有关 CloudTrail 日志条目的示例，请参阅以下主题。

------
#### [ DeleteDeliveryChannel ]

以下是该[DeleteDeliveryChannel](https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteDeliveryChannel.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:32:57Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "DeleteDeliveryChannel",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "10.24.34.0",
      "userAgent": "aws-internal/3",
      "requestParameters": {
        "deliveryChannelName": "default"
      },
      "responseElements": null,
      "requestID": "207d695a-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "5dcff7a9-e414-411a-a43e-88d122a0ad4a",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ DeliverConfigSnapshot ]

以下是该[DeliverConfigSnapshot](https://docs.aws.amazon.com/config/latest/APIReference/API_DeliverConfigSnapshot.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AIDAABCDEFGHIJKLNMOPQ:Config-API-Test",
        "arn": "arn:aws:sts::111111111111:assumed-role/JaneDoe/Config-API-Test",
        "accountId": "111111111111",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "sessionContext": {
          "attributes": {
            "mfaAuthenticated": "false",
            "creationDate": "2014-12-11T00:58:42Z"
          },
          "sessionIssuer": {
            "type": "Role",
            "principalId": "AIDAABCDEFGHIJKLNMOPQ",
            "arn": "arn:aws:iam::111111111111:role/JaneDoe",
            "accountId": "111111111111",
            "userName": "JaneDoe"
          }
        }
      },
      "eventTime": "2014-12-11T00:58:53Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "DeliverConfigSnapshot",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "10.24.34.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "deliveryChannelName": "default"
      },
      "responseElements": {
        "configSnapshotId": "58d50f10-212d-4fa4-842e-97c614da67ce"
      },
      "requestID": "e0248561-80d0-11e4-9f1c-7739d36a3df2",
      "eventID": "3e88076c-eae1-4aa6-8990-86fe52aedbd8",
      "eventType": "AwsApiCall",
      recipientAccountId": "111111111111"
    }
```

------
#### [ DescribeConfigurationRecorderStatus ]

以下是该[DescribeConfigurationRecorderStatus](https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorderStatus.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:35:44Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "DescribeConfigurationRecorderStatus",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": null,
      "responseElements": null,
      "requestID": "8442f25d-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "a675b36b-455f-4e18-a4bc-d3e01749d3f1",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ DescribeConfigurationRecorders ]

以下是该[DescribeConfigurationRecorders](https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeConfigurationRecorders.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:34:52Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "DescribeConfigurationRecorders",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": null,
      "responseElements": null,
      "requestID": "6566b55c-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "6259a9ad-889e-423b-beeb-6e1eec84a8b5",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ DescribeDeliveryChannels ]

以下是该[DescribeDeliveryChannels](https://docs.aws.amazon.com/config/latest/APIReference/API_DescribeDeliveryChannels.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:35:02Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "DescribeDeliveryChannels",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": null,
      "responseElements": null,
      "requestID": "6b6aee3f-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "3e15ebc5-bf39-4d2a-8b64-9392807985f1",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ GetResourceConfigHistory ]

以下是该[GetResourceConfigHistory](https://docs.aws.amazon.com/config/latest/APIReference/API_GetResourceConfigHistory.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AIDAABCDEFGHIJKLNMOPQ:Config-API-Test",
        "arn": "arn:aws:sts::111111111111:assumed-role/JaneDoe/Config-API-Test",
        "accountId": "111111111111",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "sessionContext": {
          "attributes": {
            "mfaAuthenticated": "false",
            "creationDate": "2014-12-11T00:58:42Z"
          },
          "sessionIssuer": {
            "type": "Role",
            "principalId": "AIDAABCDEFGHIJKLNMOPQ",
            "arn": "arn:aws:iam::111111111111:role/JaneDoe",
            "accountId": "111111111111",
            "userName": "JaneDoe"
          }
        }
      },
      "eventTime": "2014-12-11T00:58:42Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "GetResourceConfigHistory",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "10.24.34.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "resourceId": "vpc-a12bc345",
        "resourceType": "AWS::EC2::VPC",
        "limit": 0,
        "laterTime": "Dec 11, 2014 12:58:42 AM",
        "earlierTime": "Dec 10, 2014 4:58:42 PM"
      },
      "responseElements": null,
      "requestID": "d9f3490d-80d0-11e4-9f1c-7739d36a3df2",
      "eventID": "ba9c1766-d28f-40e3-b4c6-3ffb87dd6166",
      "eventType": "AwsApiCall",
      "recipientAccountId": "111111111111"
      }
```

------
#### [ PutConfigurationRecorder ]

以下是该[PutConfigurationRecorder](https://docs.aws.amazon.com/config/latest/APIReference/API_PutConfigurationRecorder.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:35:23Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "PutConfigurationRecorder",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "configurationRecorder": {
          "name": "default",
          "roleARN": "arn:aws:iam::222222222222:role/config-role-pdx"
        }
      },
      "responseElements": null,
      "requestID": "779f7917-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "c91f3daa-96e8-44ee-8ddd-146ac06565a7",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ PutDeliveryChannel ]

以下是该[PutDeliveryChannel](https://docs.aws.amazon.com/config/latest/APIReference/API_PutDeliveryChannel.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:33:08Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "PutDeliveryChannel",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "deliveryChannel": {
          "name": "default",
          "s3BucketName": "config-api-test-pdx",
          "snsTopicARN": "arn:aws:sns:us-west-2:222222222222:config-api-test-pdx"
        }
      },
      "responseElements": null,
      "requestID": "268b8d4d-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "b2db05f1-1c73-4e52-b238-db69c04e8dd4",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ StartConfigurationRecorder ]

以下是该[StartConfigurationRecorder](https://docs.aws.amazon.com/config/latest/APIReference/API_StartConfigurationRecorder.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:35:34Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "StartConfigurationRecorder",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "configurationRecorderName": "default"
      },
      "responseElements": null,
      "requestID": "7e03fa6a-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "55a5507f-f306-4896-afe3-196dc078a88d",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------
#### [ StopConfigurationRecorder ]

以下是该[StopConfigurationRecorder](https://docs.aws.amazon.com/config/latest/APIReference/API_StopConfigurationRecorder.html)操作的 CloudTrail 日志文件示例。

```
{
      "eventVersion": "1.02",
      "userIdentity": {
        "type": "IAMUser",
        "principalId": "AIDACKCEVSQ6C2EXAMPLE",
        "arn": "arn:aws:iam::222222222222:user/JohnDoe",
        "accountId": "222222222222",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "userName": "JohnDoe"
      },
      "eventTime": "2014-12-11T18:35:13Z",
      "eventSource": "config.amazonaws.com",
      "eventName": "StopConfigurationRecorder",
      "awsRegion": "us-west-2",
      "sourceIPAddress": "192.0.2.0",
      "userAgent": "aws-cli/1.2.11 Python/2.7.4 Linux/2.6.18-164.el5",
      "requestParameters": {
        "configurationRecorderName": "default"
      },
      "responseElements": null,
      "requestID": "716deea3-8164-11e4-ab4f-657c7ab282ab",
      "eventID": "6225a85d-1e49-41e9-bf43-3cfc5549e560",
      "eventType": "AwsApiCall",
      "recipientAccountId": "222222222222"
    }
```

------

# 监控
<a name="monitoring"></a>

您可以使用其他 AWS 服务来监控 AWS Config 资源。
+ 每次由于用户 API 活动而创建、更新或以其他方式修改支持的 AWS 资源时，您都可以使用亚马逊简单通知服务 (SNS) Simple Notification Service 向您发送通知。
+ 您可以使用 Amazon EventBridge 来检测 AWS Config 事件状态的变化并做出反应。

**Topics**
+ [使用 Amazon SQS](monitor-resource-changes.md)
+ [使用亚马逊 EventBridge](monitor-config-with-cloudwatchevents.md)

# 使用 Amazon SQS 监控 AWS 资源变化
<a name="monitor-resource-changes"></a>

AWS Config 每次由于用户 API 活动而创建、更新或以其他方式修改支持的 AWS 资源时，都会使用亚马逊简单通知服务 (SNS) Simple Notification Service 向您发送通知。但是您可能只关注特定资源配置的更改。例如，您可能认为必须在有人修改了安全组配置时了解这一情况，但不需要在您的 Amazon EC2 实例标签每次更改时都得到通知。或者，您可能想要编写一个在指定资源被更新时执行指定操作的程序。例如，您可能想要在某个安全组的配置发生更改时启动特定工作流程。如果您想通过这些或其他方式以编程方式使用来自 AWS Config 的数据，请使用亚马逊简单队列服务队列作为 Amazon SNS 的通知终端节点。

**注意**  
Amazon SNS 发出的通知的形式可以是电子邮件、发送到支持短信服务功能的手机和智能手机上的短信服务（SMS）消息、发送到移动设备应用程序上的通知消息，或者发送到一个或多个 HTTP 或 HTTPS 端点的通知消息。

无论每个区域只订阅一个主题还是每个区域的每个账户只订阅一个主题，您都可以使用单个 SQS 队列订阅多个主题。您必须用队列订阅您需要的 SNS 主题。(您可以用多个队列订阅一个 SNS 主题。） 有关更多信息，请参阅[将 Amazon SNS 消息发送到 Amazon SQS 队列](https://docs.aws.amazon.com/sns/latest/dg/SendMessageToSQS.html)。

## Amazon SQS 的权限
<a name="sqs-policy"></a>

要将 Amazon SQS 与配合使用 AWS Config，您必须配置一项策略，向您的账户授予执行所有 SQS 队列所允许的操作的权限。以下示例策略授予账户 111122223333 和 444455556666 权限，允许其在名为 arn:aws:sqs:us-east-2:444455556666:queue1. 的队列每次发生配置更改时发送相关消息。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Id": "Queue1_Policy_UUID",
  "Statement": 
    {
       "Sid":"Queue1_SendMessage",
       "Effect": "Allow",
       "Principal": {
            "AWS": ["111122223333","444455556666"]
         },
        "Action": "sqs:SendMessage",
        "Resource": "arn:aws:sqs:us-east-2:444455556666:queue1"
     }
}
```

------

您还必须创建一项策略，授予 SNS 主题和订阅该主题的 SQS 队列之间的连接权限。以下是一个策略示例，它允许使用亚马逊资源名称 (ARN) 的 SNS 主题 arn: aws: sns: us-east-2:111122223333: test-topic 对名为 arn: aws: sqs: us-east-2:111122223333: 的队列执行任何操作。test-topic-queue

**注意**  
SNS 主题和 SQS 队列的账户必须处于同一区域中。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Id": "SNStoSQS",
  "Statement": 
    {
      "Sid":"rule1",
      "Effect": "Allow",
      "Principal": {
        "Service": "sns.amazonaws.com"
      },
      "Action": "SQS:SendMessage",
      "Resource": "arn:aws:sqs:us-east-2:111122223333:test-topic-queue",
      "Condition" : {
        "StringEquals" : {
          "aws:SourceArn":"arn:aws:sns:us-east-2:111122223333:test-topic"
        }
      }
    }
}
```

------

每项策略中的规定可以只针对一个队列而不是多个队列。有关 Amazon SQS 策略受到的其他限制的信息，请参阅 [Amazon SQS 策略的特别信息](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AccessPolicyLanguage_SpecialInfo.html)。

# AWS Config 使用 Amazon 进行监控 EventBridge
<a name="monitor-config-with-cloudwatchevents"></a>

Amazon EventBridge 提供了描述 AWS 资源变化的近乎实时的系统事件流。使用 Amazon EventBridge 来检测 AWS Config 事件状态的变化并做出反应。

您可以创建一个规则，只要状态发生变换或者在变换到一个或多个感兴趣的状态时，就运行该规则。然后，当事件与您在规则中指定的值相匹配时，Amazon 会根据您创建的规则 EventBridge 调用一个或多个目标操作。根据事件类型，您可能想要发送通知、捕获事件信息、采取纠正措施、启动事件或采取其他操作。

但是 AWS Config，在为创建事件规则之前，应执行以下操作：
+ 熟悉中的事件、规则和目标。 EventBridge有关更多信息，请参阅[什么是亚马逊 EventBridge？](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-what-is.html)
+ 有关如何开始使用 EventBridge 和设置规则的更多信息，请参阅 [Amazon 入门 EventBridge](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-get-started.html)。
+ 创建将在您的事件规则中使用的目标。

**Topics**
+ [注意事项](#monitor-config-with-cloudwatchevents-considerations)
+ [Amazon EventBridge 格式为 AWS Config](#cloudwatch-event-format-for-awsconfig)
+ [为以下各项创建亚马逊 EventBridge 规则 AWS Config](#create-cloudwatch-events-rule-for-awsconfig)

## 注意事项
<a name="monitor-config-with-cloudwatchevents-considerations"></a>

如果您不使用以下资源类型录制警报，则不会通过 EventBridge 以下方式接收警报 AWS Config：
+ `AWS::ACM::Certificate`
+ `AWS::CloudTrail::Trail`
+ `AWS::CloudWatch::Alarm`
+ `AWS::EC2::CustomerGateway`
+ `AWS::EC2::EIP`
+ `AWS::EC2::Host`
+ `AWS::EC2::Instance`
+ `AWS::EC2::InternetGateway`
+ `AWS::EC2::NetworkAcl`
+ `AWS::EC2::NetworkInterface`
+ `AWS::EC2::RouteTable`
+ `AWS::EC2::SecurityGroup`
+ `AWS::EC2::Subnet`
+ `AWS::EC2::VPC`
+ `AWS::EC2::VPNConnection`
+ `AWS::EC2::VPNGateway`
+ `AWS::EC2::Volume`
+ `AWS::ElasticLoadBalancingV2::LoadBalancer`
+ `AWS::IAM::Group`
+ `AWS::IAM::Policy`
+ `AWS::IAM::Role`
+ `AWS::IAM::User`
+ `AWS::RDS::DBInstance`
+ `AWS::RDS::DBSecurityGroup`
+ `AWS::RDS::DBSnapshot`
+ `AWS::RDS::DBSubnetGroup`
+ `AWS::RDS::EventSubscription`
+ `AWS::Redshift::Cluster`
+ `AWS::Redshift::ClusterParameterGroup`
+ `AWS::Redshift::ClusterSecurityGroup`
+ `AWS::Redshift::ClusterSnapshot`
+ `AWS::Redshift::ClusterSubnetGroup`
+ `AWS::Redshift::EventSubscription`
+ `AWS::S3::Bucket`

## Amazon EventBridge 格式为 AWS Config
<a name="cloudwatch-event-format-for-awsconfig"></a>

 EventBridge [的事件](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-events.html) AWS Config 采用以下格式：

```
          {
             "version": "0",
             "id": "cd4d811e-ab12-322b-8255-872ce65b1bc8",
             "detail-type": "event type",
             "source": "aws.config",
             "account": "111122223333",
             "time": "2018-03-22T00:38:11Z",
             "region": "us-east-1",
             "resources": [
                resources
             ],
             "detail": {
                specific message type
             }
          }
```

## 为以下各项创建亚马逊 EventBridge 规则 AWS Config
<a name="create-cloudwatch-events-rule-for-awsconfig"></a>

使用以下步骤创建触发事件的 EventBridge 规则。 AWS Config尽最大努力发出事件。

1. 在导航窗格中，选择**规则**。

1. 选择**创建规则**。

1. 为规则输入名称和描述。

   规则不能与同一区域中的另一个规则和同一事件总线上的名称相同。
**注意**  
事件总线从源接收事件，通过规则对事件进行评估，应用所有已配置的输入转换，然后将事件路由至相应的一个或多个目标。您的账户有一个默认事件总线，它接收来自 AWS 服务的事件。自定义事件总线可以从您的自定义应用程序和服务接收事件。合作伙伴事件总线从 SaaS 合作伙伴创建的事件源接收事件。这些事件来自合作伙伴的服务或应用程序。有关更多信息，请参阅《亚马逊* EventBridge 用户指南》 EventBridge中的 Amaz* [on 事件总线](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)。

1. 对于**规则类型**，选择**具有事件模式的规则**。

1. 对于**事件来源**，选择**AWS 事件或 EventBridge 合作伙伴事件**。

1. （可选）对于**示例事件类型**，选择 **AWS 事件**。

1. （可选）对于**示例事件**，选择用于触发此规则的事件类型：
   + 选择 **AWS API 调用来源 CloudTrail**以根据对此服务进行的 API 调用制定规则。有关创建此类规则的更多信息，请参阅[教程：为 AWS CloudTrail API 调用创建 Amazon EventBridge 规则](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ct-api-tutorial.html)。
   + 选择 **Config Configuration Item Change** 以在您账户中的资源发生更改时获取通知。

     如这些支持文章中所述，在创建或删除资源时，您可以使用 EventBridge 接收自定义电子邮件通知。在[我的 using AWS Config 服务中创建资源时，如何接收自定义电子邮件通知？ AWS 账户](https://aws.amazon.com/premiumsupport/knowledge-center/config-email-resource-created/) 以及当[我的 AWS 账户 使用 AWS Config 服务中的资源被删除时，如何才能收到自定义电子邮件通知？](https://aws.amazon.com/premiumsupport/knowledge-center/config-email-resource-deleted/) 。
   + 选择 **Config Rules Compliance Change** 以在对您的规则进行合规性检查失败时获取通知。

     如本支持文章所述，当资源不合规时，您可以使用 EventBridge 接收自定义电子邮件通知，当资源不合规[时，如何使用通知我](https://repost.aws/knowledge-center/config-resource-non-compliant)？ AWS AWS Config。
   + 选择 **Config Rules Re-evaluation Status** 以获取重新评估状态通知。
   + 选择 **Config Configuration Snapshot Delivery Status** 以获取配置快照传输状态通知。
   + 选择 **Config Configuration History Delivery Status** 以获取配置历史记录传输状态通知。

1. 对于**创建方法**，选择**使用模式表单**。

1. 对于**事件源**，选择**AWS 服务**。

1. 对于 **AWS 服务**，请选择 **Config**。

1. 对于**事件类型**，选择用于触发此规则的事件类型：
   + 选择 “**所有事件**” 以制定适用于所有 AWS 服务的规则。如果选择此选项，则无法选择特定的消息类型、规则名称、资源类型或资源 IDs。
   + 选择 **AWS API 调用来源 CloudTrail**以根据对此服务进行的 API 调用制定规则。有关创建此类规则的更多信息，请参阅[教程：为 AWS CloudTrail API 调用创建 Amazon EventBridge 规则](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ct-api-tutorial.html)。
   + 选择 **Config Configuration Item Change** 以在您账户中的资源发生更改时获取通知。

     如这些支持文章中所述，在创建或删除资源时，您可以使用 EventBridge 接收自定义电子邮件通知。在[我的 using AWS Config 服务中创建资源时，如何接收自定义电子邮件通知？ AWS 账户](https://aws.amazon.com/premiumsupport/knowledge-center/config-email-resource-created/) 以及当[我的 AWS 账户 使用 AWS Config 服务中的资源被删除时，如何才能收到自定义电子邮件通知？](https://aws.amazon.com/premiumsupport/knowledge-center/config-email-resource-deleted/) 。
   + 选择 **Config Rules Compliance Change** 以在对您的规则进行合规性检查失败时获取通知。

     如本支持文章所述，当资源不合规时，您可以使用 EventBridge 接收自定义电子邮件通知，当资源不合规[时，如何使用通知我](https://repost.aws/knowledge-center/config-resource-non-compliant)？ AWS AWS Config。
   + 选择 **Config Rules Re-evaluation Status** 以获取重新评估状态通知。
   + 选择 **Config Configuration Snapshot Delivery Status** 以获取配置快照传输状态通知。
   + 选择 **Config Configuration History Delivery Status** 以获取配置历史记录传输状态通知。

1. 选择 **Any message type** 以接收任何类型的通知。选择 **Specific message type(s）** 以接收以下类型的通知：
   + 如果您愿意 **ConfigurationItemChangeNotification**，则在 AWS Config 评估的资源的配置发生变化时，您会收到消息。
   + 如果您愿意 **ComplianceChangeNotification**，则在 AWS Config 评估的资源的合规性类型发生变化时，您会收到消息。
   + 如果您愿意 **ConfigRulesEvaluationStarted**，则在 AWS Config 开始针对指定资源评估您的规则时，您会收到消息。
   + 如果您愿意 **ConfigurationSnapshotDeliveryCompleted**，则在 AWS Config 成功将配置快照传送到您的 Amazon S3 存储桶时，您会收到消息。
   + 如果您愿意 **ConfigurationSnapshotDeliveryFailed**，则在 AWS Config 无法将配置快照传送到您的 Amazon S3 存储桶时，您会收到消息。
   + 如果您愿意 **ConfigurationSnapshotDeliveryStarted**，则在 AWS Config 开始将配置快照传送到您的 Amazon S3 存储桶时会收到消息。
   + 如果您愿意 **ConfigurationHistoryDeliveryCompleted**，则在 AWS Config 成功将配置历史记录传送到您的 Amazon S3 存储桶时，您会收到消息。

1. 如果您从 “事件类型” 下拉列表中选择了特定的**事件类型**，请选择 “**任何资源类型**”，以制定适用于所有 AWS Config 支持的资源类型的规则。

   或者，选择 **Specific resource type(s）（特定资源类型）**，然后键入 AWS Config 支持的资源类型（例如，`AWS::EC2::Instance`）。

1. 如果您从**事件类型**下拉列表中选择了某个特定事件类型，请选择**任何资源 ID**，以包括 AWS Config 支持的任何资源 ID。

   或者，选择 **Specific resource ID(s）（特定资源 ID）**，然后键入 AWS Config 支持的资源 ID（例如，`i-04606de676e635647`）。

1. 如果您从**事件类型**下拉列表中选择了某个特定事件类型，请选择**任何规则名称**，以包括 AWS Config 支持的任何规则。

   或者，选择 **Specific rule name(s）（特定规则名称）**，然后键入 AWS Config 支持的规则（例如，**required-tags**）。

1. 对于**选择目标**，选择您准备为此规则使用的目标类型，然后配置该类型所需的任何其他选项。

1. 显示的字段因您选择的服务而异。根据需要输入此目标类型的特定信息。

1. 对于许多目标类型， EventBridge 需要向目标发送事件的权限。在这些情况下， EventBridge 可以创建规则运行所需的 IAM 角色。
   + 若要自动创建 IAM 角色，请选择 **Create a new role for this specific resource（为此特定资源创建新角色）**。
   + 要使用您之前创建的 IAM 角色，请选择 **Use existing role（使用现有角色）**。

1. （可选）选择 **Add target（添加目标）**，以便为此规则添加另一个目标。

1. （可选）为规则输入一个或多个标签。有关更多信息，请参阅 [Amazon EventBridge 标签](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-tagging.html)。

1. 审查您的规则设置以确保其符合事件监控要求。

1. 选择**创建**以确认您的选择。