

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

# 在 中記錄和監控 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>

當您建立帳戶 AWS 帳戶 時，您的 上會啟用 CloudTrail。當活動在 中發生時 AWS Config，該活動會與**事件歷史記錄**中的其他 AWS 服務事件一起記錄在 CloudTrail 事件中。您可以在 中檢視、搜尋和下載最近的事件 AWS 帳戶。如需詳細資訊，請參閱《使用 CloudTrail 事件歷史記錄檢視事件》[https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html](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)
+ [設定 CloudTrail 的 Amazon SNS 通知](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)

CloudTrail 會記錄所有 AWS Config 操作，並記錄在 [AWS Config API 參考](https://docs.aws.amazon.com/config/latest/APIReference/)中。例如，呼叫 [DeliverConfigSnapshot](https://docs.aws.amazon.com/config/latest/APIReference/API_DeliverConfigSnapshot.html)、[DeleteDeliveryChannel](https://docs.aws.amazon.com/config/latest/APIReference/API_DeleteDeliveryChannel.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 資源。
+ 您可以使用 Amazon Simple Notification Service (SNS)，在每次建立、更新或因使用者 API 活動而修改支援 AWS 的資源時傳送通知給您。
+ 您可以使用 Amazon EventBridge 來偵測及回應 AWS Config 事件狀態的變更。

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

# 使用 Amazon SQS 監控 AWS 資源變更
<a name="monitor-resource-changes"></a>

AWS Config 每次建立、更新或因使用者 API 活動而修改支援 AWS 的資源時， 都會使用 Amazon Simple Notification Service (SNS) 傳送通知給您。但是，您可能只關心特定資源的組態變更。例如，您可能認為知道有人修改安全群組的組態非常重要，但不需要知道 Amazon EC2 執行個體每一次的標籤變更。或者，您可能希望撰寫在特定資源更新時執行特定動作的程式。例如，您可能會希望在安全群組組態變更時啟動特定工作流程。如果您想要 AWS Config 以程式設計方式使用這些或其他方式使用來自 的資料，請使用 Amazon Simple Queue Service 佇列做為 Amazon SNS 的通知端點。

**注意**  
從 Amazon SNS 傳送通知的形式也可能為：電子郵件、傳送至啟用 SMS 的行動電話及智慧型手機的簡訊服務 (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 佇列之間連線的許可。下列範例政策會許可 Amazon Resource Name (ARN) 為 arn:aws:sns:us-east-2:111122223333:test-topic 的 SNS 主題，在名為 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 中的事件、規則和目標。如需詳細資訊，請參閱[什麼是 Amazon 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)
+ [建立 的 Amazon 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
             }
          }
```

## 建立 的 Amazon EventBridge 規則 AWS Config
<a name="create-cloudwatch-events-rule-for-awsconfig"></a>

使用下列步驟建立會在 AWS Config發出事件時觸發的 EventBridge 規則。盡可能發出事件。

1. 在導覽窗格中，選擇**規則**。

1. 選擇**建立規則**。

1. 輸入規則的名稱和描述。

   在同一個區域和同一個事件匯流排上，規則不能與另一個規則同名。
**注意**  
事件匯流排從來源接收事件、使用規則來評估事件、套用任何設定的輸入轉換，並將它們路由到適當的目標 ()。您帳戶的預設事件匯流排會從 接收事件 AWS 服務。自訂事件匯流排可以從自訂應用程式和服務接收事件。合作夥伴事件匯流排會從 SaaS 合作夥伴建立的事件來源接收事件。這些事件來自合作夥伴服務或應用程式。如需詳細資訊，請參閱《[Amazon EventBridge 使用者指南》中的 Amazon EventBridge 中的事件匯流排](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-bus.html)。 * EventBridge *

1. 針對**規則類型**，選擇**具有事件模式的規則**。

1. 在**事件來源**欄位中，選擇 **AWS 事件或 EventBridge 合作夥伴事件**。

1. (選用) **範例事件類型** 請選擇 **AWS 事件**。

1. (選用) **範例事件** 請選擇會觸發以下規則的事件類型：
   + **AWS 從 CloudTrail 選擇 API 呼叫**，以對此服務進行的 API 呼叫為基礎。如需建立此類型規則的詳細資訊，請參閱[教學課程：建立 AWS CloudTrail API 呼叫的 Amazon EventBridge 規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ct-api-tutorial.html)。
   + 選擇 **Config Configuration Item Change (設定組態項目變更)** 以在您帳戶中的資源發生變更時取得通知。

     如這些支援文章所述，您可以在建立或刪除資源時，使用 EventBridge 來接收自訂電子郵件通知。[使用 AWS 帳戶AWS Config 服務建立資源時，如何接收自訂電子郵件通知？](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 來接收自訂電子郵件通知。[當 AWS 資源不合規時，如何使用 收到通知 AWS Config？](https://repost.aws/knowledge-center/config-resource-non-compliant)
   + 選擇 **Config Rules Re-evaluation Status (設定規則重新評估狀態)** 以取得重新評估狀態通知。
   + 選擇 **Config Configuration Snapshot Delivery Status (設定組態快照交付狀態)** 以取得組態快照交付狀態通知。
   + 選擇 **Config Configuration History Delivery Status (設定組態歷史記錄交付狀態)** 以取得組態歷史記錄交付狀態通知。

1. **建立方法** 請選擇 **使用模式表單**。

1. 在**事件來源**欄位中，選擇 **AWS 服務**。

1. **AWS 服務** 請選擇 **Config**。

1. **事件類型** 請選擇會觸發規則的事件類型：
   + 選擇**所有事件**以建立套用至所有 AWS 服務的規則。若您選擇此選項，您將無法選擇特定訊息類型、規則名稱、資源類型，或資源 ID。
   + **AWS 從 CloudTrail 選擇 API 呼叫**，以對此服務進行 API 呼叫為基礎。如需建立此類型規則的詳細資訊，請參閱[教學課程：建立 AWS CloudTrail API 呼叫的 Amazon EventBridge 規則](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-ct-api-tutorial.html)。
   + 選擇 **Config Configuration Item Change (設定組態項目變更)** 以在您帳戶中的資源發生變更時取得通知。

     如這些支援文章所述，您可以在建立或刪除資源時，使用 EventBridge 來接收自訂電子郵件通知。[使用 AWS 帳戶AWS Config 服務建立資源時，如何接收自訂電子郵件通知？](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 來接收自訂電子郵件通知。[當 AWS 資源不合規時，如何使用 收到通知 AWS Config？](https://repost.aws/knowledge-center/config-resource-non-compliant)
   + 選擇 **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 角色，請選擇 **為此特定資源建立新角色**。
   + 若要使用您早前建立的 IAM 角色，請選擇 **Use existing role** (使用現有角色)。

1. (選用) 選擇 **Add target (新增目標)**，為此規則新增另一個目標。

1. (選用) 為規則輸入一或多個標籤。如需詳細資訊，請參閱《[Amazon EventBridge 標籤](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-tagging.html)》。

1. 檢閱您的規則設定，確定其符合您的事件監控要求。

1. 選擇 **建立** 確認您選取的項目。