

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

# 使用记录 Macie API 调用 AWS CloudTrail
<a name="macie-cloudtrail"></a>

Amazon Macie 与[AWS CloudTrail](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-user-guide.html)集成，后者是一项服务，可记录用户、角色或角色所采取的操作。 AWS 服务 CloudTrail将 Macie 的所有 API 调用捕获为管理事件。捕获的调用中包括通过 Amazon Macie 控制台的调用和对 Amazon Macie API 操作的编程调用。通过使用收集的信息 CloudTrail，您可以确定向 Macie 发出的请求、发出请求的 IP 地址、发出请求的时间以及其他详细信息。

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

CloudTrail 在您创建账户 AWS 账户 时在您的账户中处于活动状态，并且您自动可以访问 CloudTrail **活动历史记录**。 CloudTrail **事件历史记录**提供了过去 90 天中记录的管理事件的可查看、可搜索、可下载且不可变的记录。 AWS 区域有关更多信息，请参阅《*AWS CloudTrail 用户指南》*中的[使用 CloudTrail 事件历史记录](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)。查看**活动历史记录**不 CloudTrail收取任何费用。

要持续记录过去 90 天内的事件，请 AWS 账户 创建跟踪或 CloudTrail Lake 事件数据存储。

**CloudTrail 步道**  
*跟踪*允许 CloudTrail 将日志文件传输到 Amazon S3 存储桶。使用创建的所有跟踪 AWS 管理控制台 都是多区域的。您可以通过使用 AWS CLI创建单区域或多区域跟踪。建议创建多区域跟踪，因为您可以捕获账户 AWS 区域 中的所有活动。如果您创建单区域跟踪，则只能查看跟踪的 AWS 区域中记录的事件。有关跟踪的更多信息，请参阅《AWS CloudTrail 用户指南》**中的[为您的 AWS 账户创建跟踪](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)和[为组织创建跟踪](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/creating-trail-organization.html)。  
通过创建跟踪，您可以免费将正在进行的管理事件的一份副本传送到您的 Amazon S3 存储桶，但会收取 Amazon S3 存储费用。 CloudTrail 有关 CloudTrail 定价的更多信息，请参阅[AWS CloudTrail 定价](https://aws.amazon.com/cloudtrail/pricing/)。有关 Amazon S3 定价的信息，请参阅 [Amazon S3 定价](https://aws.amazon.com/s3/pricing/)。

**CloudTrail 湖泊事件数据存储**  
CloudTrail L@@ *ak* e 允许你对自己的事件运行基于 SQL 的查询。 CloudTrail Lake 将基于行的 JSON 格式的现有事件转换为 [Apache ORC](https://orc.apache.org/) 格式。ORC 是一种针对快速检索数据进行优化的列式存储格式。事件将被聚合到*事件数据存储*中，它是基于您通过应用[高级事件选择器](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-concepts.html#adv-event-selectors)选择的条件的不可变的事件集合。应用于事件数据存储的选择器用于控制哪些事件持续存在并可供您查询。有关 CloudTrail Lake 的更多信息，请参阅《*AWS CloudTrail 用户指南》*中的 “[使用 AWS CloudTrail Lake](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html)”。  
CloudTrail 湖泊事件数据存储和查询会产生费用。创建事件数据存储时，您可以选择要用于事件数据存储的[定价选项](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake-manage-costs.html#cloudtrail-lake-manage-costs-pricing-option)。定价选项决定了摄取和存储事件的成本，以及事件数据存储的默认和最长保留期。有关 CloudTrail 定价的更多信息，请参阅[AWS CloudTrail 定价](https://aws.amazon.com/cloudtrail/pricing/)。

## 在 Macie 管理活动中 AWS CloudTrail
<a name="logging-ct-mgmt-events"></a>

[管理事件](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/logging-management-events-with-cloudtrail.html#logging-management-events)提供有关对中的资源执行的管理操作的信息 AWS 账户。这些也称为控制面板操作。默认情况下， CloudTrail 记录管理事件。

Amazon Macie 将所有 Macie 控制平面操作记录为管理事件。 CloudTrail例如，对`ListFindings``DescribeBuckets`、和`CreateClassificationJob`操作的调用会在中生成管理事件 CloudTrail。每个事件都包含 `eventSource` 字段。此字段 AWS 服务 表示已向发出请求。对于 Macie 事件，此字段的值为：`macie2.amazonaws.com`。

有关 Macie 登录的控制平面操作列表 CloudTrail，请参阅《*亚马逊 Macie API 参考*》中的[操作](https://docs.aws.amazon.com/macie/latest/APIReference/operations.html)。

## Macie 事件的示例 AWS CloudTrail
<a name="logging-ct-events-examples"></a>

事件代表来自任何来源的单个请求，包括有关所请求的 API 操作、操作的日期和时间、请求参数等的信息。 CloudTrail 日志文件不是公共 API 调用的有序堆栈跟踪，因此事件不会按任何特定顺序出现。

以下示例显示了演示 Amazon Macie 操作 CloudTrail 的事件。有关事件可能包含的信息的详细信息，请参阅*《AWS CloudTrail 用户指南》*中的[CloudTrail记录内容](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html)。

**Topics**
+ [列出调查结果](#logging-ct-events-example-listfindings)
+ [检索调查发现的敏感数据样本](#logging-ct-events-example-getsdoccurrences)
+ [删除会员邀请](#logging-ct-events-example-deleteinvitations)
+ [禁用 Macie](#logging-ct-events-example-disablemacie)

### 示例：列出调查发现
<a name="logging-ct-events-example-listfindings"></a>

以下示例显示了亚马逊 Macie [https://docs.aws.amazon.com/macie/latest/APIReference/findings.html](https://docs.aws.amazon.com/macie/latest/APIReference/findings.html)操作 CloudTrail 的事件。在此示例中，一个 AWS Identity and Access Management (IAM) 用户 (`Mary_Major`) 使用 Amazon Macie 控制台检索了有关其账户当前政策调查结果的部分信息。

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "IAMUser",
        "principalId": "123456789012",
        "arn": "arn:aws:iam::123456789012:user/Mary_Major",
        "accountId": "123456789012",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "userName": "Mary_Major",
        "sessionContext":{
            "attributes": {
                "creationdate": "2024-11-14T15:49:57Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2024-11-14T16:09:56Z",
    "eventSource": "macie2.amazonaws.com",
    "eventName": "ListFindings",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "198.51.100.1",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
    "requestParameters": {
        "sortCriteria": {
            "attributeName": "updatedAt",
            "orderBy": "DESC"
        },
        "findingCriteria": {
            "criterion": {
                "archived": {
                    "eq": [
                        "false"
                    ]
                },
                "category": {
                    "eq": [
                        "POLICY"
                    ]
                }
            }
        },
        "maxResults": 25,
        "nextToken": ""
    },
    "responseElements": null,
    "requestID": "d58af6be-1115-4a41-91f8-ace03example",
    "eventID": "ad97fac5-f7cf-4ff9-9cf2-d0676example",
    "readOnly": true,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "eventCategory": "Management"
}
```

### 示例：检索调查发现的敏感数据样本
<a name="logging-ct-events-example-getsdoccurrences"></a>

此示例显示了用于检索和泄露 Amazon Macie 在调查结果中报告的敏感数据样本 CloudTrail 的事件。在此示例中，一个 `JohnDoe`（IAM）用户使用 Amazon Macie 控制台来检索和显示敏感数据样本。该用户的账户被配置为代入 IAM 角色（`MacieReveal`）来检索和显示受影响的 Amazon Simple Storage Service (Amazon S3) 对象中的敏感数据样本。

以下事件显示了有关用户请求通过 Amazon Macie [https://docs.aws.amazon.com/macie/latest/APIReference/findings-findingid-reveal.html](https://docs.aws.amazon.com/macie/latest/APIReference/findings-findingid-reveal.html)操作检索和披露敏感数据样本的详细信息。

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "UU4MH7OYK5ZCOAEXAMPLE:JohnDoe",
        "arn": "arn:aws:sts::111122223333:assumed-role/Admin/JohnDoe",
        "accountId": "111122223333",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "UU4MH7OYK5ZCOAEXAMPLE",
                "arn": "arn:aws:iam::111122223333:role/Admin",
                "accountId": "111122223333",
                "userName": "Admin"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2024-12-12T14:40:23Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2024-12-12T17:04:47Z",
    "eventSource": "macie2.amazonaws.com",
    "eventName": "GetSensitiveDataOccurrences",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "198.51.100.252",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
    "requestParameters": {
        "findingId": "3ad9d8cd61c5c390bede45cd2example"
    },
    "responseElements": null,
    "requestID": "c30cb760-5102-47e7-88d8-ff2e8example",
    "eventID": "baf52d92-f9c3-431a-bfe8-71c81example",
    "readOnly": true,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "111122223333",
    "eventCategory": "Management"
}
```

下一个事件显示有关 Macie 然后使用 () [https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html)操作担任指定的 IAM 角色 AWS Security Token Service (`MacieReveal`AWS STS) 的详细信息。

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AWSService",
        "invokedBy": "reveal-samples.macie.amazonaws.com"
    },
    "eventTime": "2024-12-12T17:04:47Z",
    "eventSource": "sts.amazonaws.com",
    "eventName": "AssumeRole",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "reveal-samples.macie.amazonaws.com",
    "userAgent": "reveal-samples.macie.amazonaws.com",
    "requestParameters": {
        "roleArn": "arn:aws:iam::111122223333:role/MacieReveal",
        "roleSessionName": "RevealCrossAccount"
    },
    "responseElements": {
        "credentials": {
            "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
            "sessionToken": "XXYYaz...
EXAMPLE_SESSION_TOKEN
XXyYaZAz",
            "expiration": "Dec 12, 2024, 6:04:47 PM"
        },
        "assumedRoleUser": {
            "assumedRoleId": "AROAXOTKAROCSNEXAMPLE:RevealCrossAccount",
            "arn": "arn:aws:sts::111122223333:assumed-role/MacieReveal/RevealCrossAccount"
        }
    },
    "requestID": "d905cea8-2dcb-44c1-948e-19419example",
    "eventID": "74ee4d0c-932d-3332-87aa-8bcf3example",
    "readOnly": true,
    "resources": [
        {
            "accountId": "111122223333",
            "type": "AWS::IAM::Role",
            "ARN": "arn:aws:iam::111122223333:role/MacieReveal"
        }
    ],
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "111122223333",
    "eventCategory": "Management"
}
```

### 示例：删除会员邀请
<a name="logging-ct-events-example-deleteinvitations"></a>

以下示例显示了亚马逊 Macie [DeleteInvitations](https://docs.aws.amazon.com/macie/latest/APIReference/invitations-delete.html)操作 CloudTrail 的事件。在此示例中，当成员取消其帐户与管理员帐户的关联并删除管理员的加入该组织的邀请时，Macie 在组织委派的 Macie 管理员账户中记录了一个事件。在示例中，管理员的账户 ID AWS 账户 为`777788889999`。成员账户的账户 ID 是`111122223333`。

```
{
    "eventVersion": "1.11",
    "userIdentity": {
        "type": "AWSAccount",
        "accountId": "111122223333",
        "invokedBy": "macie2.amazonaws.com"
    },
    "eventTime": "2025-09-20T18:44:58Z",
    "eventSource": "macie2.amazonaws.com",
    "eventName": "MacieMemberUpdated",
    "awsRegion": "us-east-2",
    "sourceIPAddress": "macie2.amazonaws.com",
    "userAgent": "macie2.amazonaws.com",
    "requestParameters": null,
    "responseElements": null,
    "eventID": "2f08152c-66b9-35f8-8a10-6fe1bexample",
    "readOnly": false,
    "resources": [{
        "accountId": "777788889999",
        "type": "AWS::Macie::Member",
        "ARN": "arn:aws:macie2:us-east-2:777788889999:member/111122223333"
    }],
    "eventType": "AwsServiceEvent",
    "managementEvent": true,
    "recipientAccountId": "777788889999",
    "sharedEventID": "2bff2ad0-f233-48c6-8720-ca9dbexample",
    "serviceEventDetails": {
        "memberAccount": "111122223333",
        "memberResourceStatus": "DELETED",
        "apiOperation": "DeleteInvitations"
    },
    "eventCategory": "Management"
}
```

### 示例：禁用 Macie
<a name="logging-ct-events-example-disablemacie"></a>

此示例显示了禁用 Amazon Macie CloudTrail 的事件。 AWS 账户在此示例中，一个 IAM 用户 (`JohnDoe`) 为其账户禁用了 Macie。然后，Macie 取消并删除了该账户的所有敏感数据发现任务，此外还删除了该账户的其他 Macie 资源和数据。

以下事件显示了有关用户使用亚马逊 Macie 操作请求为其账户禁用 M [https://docs.aws.amazon.com/macie/latest/APIReference/macie.html](https://docs.aws.amazon.com/macie/latest/APIReference/macie.html)acie 的详细信息。

```
{
    "eventVersion": "1.09",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AROAXYKJR2G5JXEXAMPLE:JohnDoe",
        "arn": "arn:aws:sts::123456789012:assumed-role/Admin/JohnDoe",
        "accountId": "123456789012",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AROAXYKJR2G5JXEXAMPLE",
                "arn": "arn:aws:iam::123456789012:role/Admin",
                "accountId": "123456789012",
                "userName": "Admin"
            },
            "attributes": {
                "creationDate": "2025-09-18T21:54:42Z",
                "mfaAuthenticated": "true"
            }
        }
    },
    "eventTime": "2025-09-18T21:57:06Z",
    "eventSource": "macie2.amazonaws.com",
    "eventName": "DisableMacie",
    "awsRegion": "us-east-2",
    "sourceIPAddress": "198.51.100.1",
    "userAgent": "aws-cli/2.17.9 md/awscrt#0.20.11 ua/2.0 os/macos#24.4.0 md/arch#x86_64 lang/python#3.11.8 md/pyimpl#CPython cfg/retry-mode#standard md/installer#exe md/prompt#off md/command#macie2.disable-macie",
    "requestParameters": null,
    "responseElements": null,
    "requestID": "941d1d6c-c1b2-4db5-845f-1250cexample",
    "eventID": "06554dba-417b-4a65-90b8-4e5d5example",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "eventCategory": "Management"
}
```

下一个事件将显示有关 Macie 的详细信息，然后取消并删除该账户的其中一个敏感数据发现任务。

```
{
    "eventVersion": "1.11",
    "userIdentity": {
        "type": "Root",
        "accountId": "123456789012",
        "invokedBy": "macie2.amazonaws.com"
    },
    "eventTime": "2025-09-18T21:57:18Z",
    "eventSource": "macie2.amazonaws.com",
    "eventName": "MacieClassificationJobCancelled",
    "awsRegion": "us-east-2",
    "sourceIPAddress": "macie2.amazonaws.com",
    "userAgent": "macie2.amazonaws.com",
    "requestParameters": null,
    "responseElements": null,
    "eventID": "df39ea1d-cd4e-4130-8cd5-cd33cexample",
    "readOnly": false,
    "resources": [{
        "accountId": "123456789012",
        "type": "AWS::Macie::ClassificationJob",
        "ARN": "arn:aws:macie2:us-east-2:123456789012:classification-job/f252cbe854ae0a1a47d8304f4example"
    }],
    "eventType": "AwsServiceEvent",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "serviceEventDetails": {
        "macieStatus": "DISABLED",
        "classificationJobStatus": "CANCELLED"
    },
    "eventCategory": "Management"
}
```