使用 AWS CloudTrail 記錄 EBS 直接 API 的 API 呼叫 - Amazon Elastic Compute Cloud

使用 AWS CloudTrail 記錄 EBS 直接 API 的 API 呼叫

EBS Direct API 服務與 AWS CloudTrail 整合。CloudTrail 服務會提供由使用者、角色或 AWS 服務的動作記錄。CloudTrail 會將在 EBS 直接 API 執行的所有 API 呼叫擷取為事件。如果您建立追蹤,就可以將 CloudTrail 事件持續交付到 Amazon Simple Storage Service (Amazon S3) 儲存貯體。即使您未設定追蹤,依然可以透過 CloudTrail 主控台中的 Event history (事件歷史記錄) 檢視最新管理事件。事件歷史記錄中不會擷取資料事件。您可以使用由 CloudTrail 收集的資訊,來判斷對 EBS 直接 API 提出的請求、提出請求的 IP 地址、提出請求的人員、提出請求的時間,以及其他詳細資訊。

如需 CloudTrail 的詳細資訊,請參閱 AWS CloudTrail 使用者指南

CloudTrail 中的 EBS 直接 API 資訊

當您建立帳戶時,系統即會在 AWS 帳戶中啟用 CloudTrail。當 EBS 直接 API 中發生支援的事件活動時,系統會將該活動與事件歷史記錄中的其他 AWS 服務事件一併記錄在 CloudTrail 事件中。您可以檢視、搜尋和下載 AWS 帳戶的最新事件。如需詳細資訊,請參閱使用 CloudTrail 事件歷史記錄檢視事件

如需 AWS 帳戶中正在進行之事件的記錄 (包含 EBS 直接 API 的事件),請建立追蹤。線索可讓 CloudTrail 將日誌檔案傳遞到 S3 儲存貯體。根據預設,當您在主控台建立追蹤記錄時,追蹤記錄會套用到所有 AWS 區域。該追蹤會記錄來自 AWS 分割區中所有區域的事件,並將日誌檔案交付到您指定的 S3 儲存貯體。此外,您可以設定其他 AWS 服務,以進一步分析和處理 CloudTrail 日誌中所收集的事件資料。如需詳細資訊,請參閱下列內容:

支援的 API 動作

對於 EBS 直接 API,您可以使用 CloudTrail 來記錄兩種事件

  • 管理事件 – 管理事件可讓您深入了解在 AWS 帳戶中對快照執行的管理操作。下列 API 動作預設會記錄為追蹤中的管理事件:

    如需有關記錄管理事件的詳細資訊,請參閱 CloudTrail 使用者指南中的記錄追蹤的管理事件

  • 資料事件 – 這些事件可讓您深入了解對快照執行或在快照中執行的快照操作。您可以選擇性地將下列 API 動作記錄為追蹤中的資料事件:

    根據預設,在您建立追蹤時,不會記錄資料事件。您只能使用進階事件選取器來記錄 EBS 直接 API 呼叫的資料事件。如需詳細資訊,請參閱 CloudTrail 使用者指南中的記錄追蹤的資料事件

    注意

    如果您在與您共用的快照上執行動作,系統就不會將資料事件傳送至擁有快照的 AWS 帳戶。

身分資訊

每一筆事件或日誌項目都會包含產生請求者的資訊。身分資訊可協助您判斷下列事項:

  • 該請求是否透過根或 AWS Identity and Access Management (IAM) 使用者憑證來提出。

  • 提出該要求時,是否使用了特定角色或聯合身分使用者的暫時安全憑證。

  • 該請求是否由另一項 AWS 服務提出。

如需詳細資訊,請參閱 CloudTrail userIdentityElement

了解 EBS 直接 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" } }