使用 AWS CloudTrail 记录 EBS direct API 的 API 调用 - Amazon Elastic Compute Cloud

使用 AWS CloudTrail 记录 EBS direct API 的 API 调用

EBS direct API 服务已与 AWS CloudTrail 集成。CloudTrail 是提供用户、角色或 AWS 服务所采取操作的记录的服务。CloudTrail 将在 EBS direct API 中执行的所有 API 调用作为事件捕获。如果您创建跟踪记录,则可以使 CloudTrail 事件持续传送到 Amazon Simple Storage Service (Amazon S3) 存储桶。如果您不配置跟踪记录,则仍可在 CloudTrail 控制台中的 Event history(事件历史记录)中查看最新管理事件。事件历史记录中不会捕获数据事件。可以使用 CloudTrail 收集的信息确定向 EBS direct API 发出了什么请求、发出请求的 IP 地址、何人发出的请求、请求的发出时间以及其他详细信息。

有关 CloudTrail 的更多信息,请参阅 AWS CloudTrail 用户指南

CloudTrail 中的 EBS direct API 信息

在您创建 AWS 账户时,将在该账户上启用 CloudTrail。当 EBS direct API 中发生受支持的事件活动时,该活动将记录在 CloudTrail 事件中,并与其他 AWS 服务事件一同保存在 Event history(事件历史记录)中。您可以在 AWS 账户中查看、搜索和下载最新事件。有关更多信息,请参阅使用 CloudTrail 事件历史记录查看事件

要持续记录 AWS 账户中的事件(包括 EBS direct API 的事件),请创建跟踪记录。通过跟踪,CloudTrail 可将日志文件传送至 S3 存储桶。默认情况下,在控制台中创建跟踪时,此跟踪应用于所有 AWS 区域。此跟踪在 AWS 分区中记录所有区域中的事件,并将日志文件传送至您指定的 S3 存储桶。此外,您可以配置其他 AWS 服务,进一步分析在 CloudTrail 日志中收集的事件数据并采取行动。有关更多信息,请参阅下列内容:

支持的 API 操作

对于 EBS 直接 API,您可以使用 CloudTrail 记录两种类型的事件

  • 管理事件 — 通过管理事件,可以了解对在您 AWS 账户内的快照上执行的管理操作。以下 API 操作预设情况下将作为管理事件记录在跟踪记录中:

    有关日志记录管理事件的更多信息,请参阅 CloudTrail 用户指南中的记录跟踪记录的管理事件

  • Data events(数据事件) — 通过这些事件,可以了解对快照执行的或在快照内执行的快照操作。以下 API 操作可以选择作为跟踪中的数据事件记录:

    预设情况下,在您创建跟踪记录时,未记录数据事件。您只能使用 advanced event selectors(高级事件选择器)来记录 EBS direct API 调用上的数据事件。有关更多信息,请参阅 CloudTrail 用户指南中的记录数据事件以便跟踪

    注意

    如果您对与您共享的快照执行操作,则数据事件不会发送到拥有快照的 AWS 账户。

身份信息

每个事件或日志条目都包含有关生成请求的人员信息。身份信息可帮助您确定以下内容:

  • 请求是使用根用户凭证还是 AWS Identity and Access Management(IAM) 用户凭证发出的。

  • 请求是使用角色还是联合身份用户的临时安全凭证发出的。

  • 请求是否由其它 AWS 服务发出。

有关更多信息,请参阅 CloudTrail userIdentityElement

了解 EBS direct API 日志文件条目

跟踪是一种配置,可用于将事件作为日志文件传送到您指定的 S3 存储桶。CloudTrail 日志文件包含一个或多个日志条目。一个事件表示来自任何源的一个请求,包括有关所请求的操作、操作的日期和时间、请求参数等方面的信息。CloudTrail 日志文件不是公用 API 调用的有序堆栈跟踪,因此它们不会按任何特定顺序显示。

以下是示例 CloudTrail 日志条目。

StartSnapshot
{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2020-07-03T23:27:26Z", "eventSource": "ebs.amazonaws.com", "eventName": "StartSnapshot", "awsRegion": "eu-west-1", "sourceIPAddress": "192.0.2.0", "userAgent": "PostmanRuntime/7.25.0", "requestParameters": { "volumeSize": 8, "clientToken": "token", "encrypted": true }, "responseElements": { "snapshotId": "snap-123456789012", "ownerId": "123456789012", "status": "pending", "startTime": "Jul 3, 2020 11:27:26 PM", "volumeSize": 8, "blockSize": 524288, "kmsKeyArn": "HIDDEN_DUE_TO_SECURITY_REASONS" }, "requestID": "be112233-1ba5-4ae0-8e2b-1c302EXAMPLE", "eventID": "6e12345-2a4e-417c-aa78-7594fEXAMPLE", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }
CompleteSnapshot
{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2020-07-03T23:28:24Z", "eventSource": "ebs.amazonaws.com", "eventName": "CompleteSnapshot", "awsRegion": "eu-west-1", "sourceIPAddress": "192.0.2.0", "userAgent": "PostmanRuntime/7.25.0", "requestParameters": { "snapshotId": "snap-123456789012", "changedBlocksCount": 5 }, "responseElements": { "status": "completed" }, "requestID": "be112233-1ba5-4ae0-8e2b-1c302EXAMPLE", "eventID": "6e12345-2a4e-417c-aa78-7594fEXAMPLE", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }
ListSnapshotBlocks
{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AIDAT4HPB2AO3JEXAMPLE", "arn": "arn:aws:iam::123456789012:user/user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2021-06-03T00:32:46Z", "eventSource": "ebs.amazonaws.com", "eventName": "ListSnapshotBlocks", "awsRegion": "us-east-1", "sourceIPAddress": "111.111.111.111", "userAgent": "PostmanRuntime/7.28.0", "requestParameters": { "snapshotId": "snap-abcdef01234567890", "maxResults": 100, "startingBlockIndex": 0 }, "responseElements": null, "requestID": "example6-0e12-4aa9-b923-1555eexample", "eventID": "example4-218b-4f69-a9e0-2357dexample", "readOnly": true, "resources": [ { "accountId": "123456789012", "type": "AWS::EC2::Snapshot", "ARN": "arn:aws:ec2:us-west-2::snapshot/snap-abcdef01234567890" } ], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "123456789012", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-SHA", "clientProvidedHostHeader": "ebs.us-west-2.amazonaws.com" } }
ListChangedBlocks
{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AIDAT4HPB2AO3JEXAMPLE", "arn": "arn:aws:iam::123456789012:user/user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2021-06-02T21:11:46Z", "eventSource": "ebs.amazonaws.com", "eventName": "ListChangedBlocks", "awsRegion": "us-east-1", "sourceIPAddress": "111.111.111.111", "userAgent": "PostmanRuntime/7.28.0", "requestParameters": { "firstSnapshotId": "snap-abcdef01234567890", "secondSnapshotId": "snap-9876543210abcdef0", "maxResults": 100, "startingBlockIndex": 0 }, "responseElements": null, "requestID": "example0-f4cb-4d64-8d84-72e1bexample", "eventID": "example3-fac4-4a78-8ebb-3e9d3example", "readOnly": true, "resources": [ { "accountId": "123456789012", "type": "AWS::EC2::Snapshot", "ARN": "arn:aws:ec2:us-west-2::snapshot/snap-abcdef01234567890" }, { "accountId": "123456789012", "type": "AWS::EC2::Snapshot", "ARN": "arn:aws:ec2:us-west-2::snapshot/snap-9876543210abcdef0" } ], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "123456789012", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-SHA", "clientProvidedHostHeader": "ebs.us-west-2.amazonaws.com" } }
GetSnapshotBlock
{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AIDAT4HPB2AO3JEXAMPLE", "arn": "arn:aws:iam::123456789012:user/user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2021-06-02T20:43:05Z", "eventSource": "ebs.amazonaws.com", "eventName": "GetSnapshotBlock", "awsRegion": "us-east-1", "sourceIPAddress": "111.111.111.111", "userAgent": "PostmanRuntime/7.28.0", "requestParameters": { "snapshotId": "snap-abcdef01234567890", "blockIndex": 1, "blockToken": "EXAMPLEiL5E3pMPFpaDWjExM2/mnSKh1mQfcbjwe2mM7EwhrgCdPAEXAMPLE" }, "responseElements": null, "requestID": "examplea-6eca-4964-abfd-fd9f0example", "eventID": "example6-4048-4365-a275-42e94example", "readOnly": true, "resources": [ { "accountId": "123456789012", "type": "AWS::EC2::Snapshot", "ARN": "arn:aws:ec2:us-west-2::snapshot/snap-abcdef01234567890" } ], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "123456789012", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-SHA", "clientProvidedHostHeader": "ebs.us-west-2.amazonaws.com" } }
PutSnapshotBlock
{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AIDAT4HPB2AO3JEXAMPLE", "arn": "arn:aws:iam::123456789012:user/user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "user" }, "eventTime": "2021-06-02T21:09:17Z", "eventSource": "ebs.amazonaws.com", "eventName": "PutSnapshotBlock", "awsRegion": "us-east-1", "sourceIPAddress": "111.111.111.111", "userAgent": "PostmanRuntime/7.28.0", "requestParameters": { "snapshotId": "snap-abcdef01234567890", "blockIndex": 1, "dataLength": 524288, "checksum": "exampleodSGvFSb1e3kxWUgbOQ4TbzPurnsfVexample", "checksumAlgorithm": "SHA256" }, "responseElements": { "checksum": "exampleodSGvFSb1e3kxWUgbOQ4TbzPurnsfVexample", "checksumAlgorithm": "SHA256" }, "requestID": "example3-d5e0-4167-8ee8-50845example", "eventID": "example8-4d9a-4aad-b71d-bb31fexample", "readOnly": false, "resources": [ { "accountId": "123456789012", "type": "AWS::EC2::Snapshot", "ARN": "arn:aws:ec2:us-west-2::snapshot/snap-abcdef01234567890" } ], "eventType": "AwsApiCall", "managementEvent": false, "recipientAccountId": "123456789012", "eventCategory": "Data", "tlsDetails": { "tlsVersion": "TLSv1.2", "cipherSuite": "ECDHE-RSA-AES128-SHA", "clientProvidedHostHeader": "ebs.us-west-2.amazonaws.com" } }