使用 CloudTrail 记录 AWS Backup API 调用 - AWS Backup
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

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

使用 CloudTrail 记录 AWS Backup API 调用

AWS Backup 与 AWS CloudTrail 集成,后者是一项提供 AWS BackAWS Backup 中用户、角色或 AWS 服务所采取操作的记录的服务。CloudTrail 将 AWS Backup 的所有 API 调用作为事件捕获。捕获的调用包括来自 AWS Backup 控制台的调用和对 AWS Backup API 操作的代码调用。如果您创建跟踪,则可以使 CloudTrail 事件持续传送到 Amazon S3 存储桶(包括 AWS Backup 的事件)。如果您不配置跟踪,则仍可在 CloudTrail 控制台中的 Event history (事件历史记录) 中查看最新事件。使用 CloudTrail 收集的信息,您可以确定向 AWS Backup 发出了什么请求、发出请求的 IP 地址、请求的发出时间以及其他详细信息。要了解 CloudTrail 的更多信息,请参阅 AWS CloudTrail 用户指南

CloudTrail 中的 AWS Backup 信息

在您创建 AWS 账户时,将在该账户上启用 CloudTrail。当 AWS Backup 中发生活动时,该活动将记录在 CloudTrail 事件中,并与其他 AWS 服务事件一同保存在事件历史记录。您可以在 AWS 账户中查看、搜索和下载最新事件。AWS Backup 在执行备份、恢复或复制时会生成以下 CloudTrail 事件:

  • BackupDeleted

  • BackupJobCompleted

  • BackupJobStarted

  • BackupSelectionDeletedDueToSLRDeletion

  • BackupTransitionedToCold

  • CopyJobCompleted

  • CopyJobStarted

  • RestoreCompleted

  • RestoreStarted

这些事件不一定是通过使用 AWS Backup 公共 API 生成的。相反,它们是通过 AWS Backup 异步执行您的任务生成的。例如,您的StartBackupJobAPI 调用可能会生成BackupJobStarted事件,但是备份计划中的计划作业也可以生成BackupJobStartedevent.

有关更多信息,请参阅使用 CloudTrail 事件历史记录查看事件

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

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

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

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

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

有关更多信息,请参阅 CloudTrail userIdentity 元素

了解 AWS Backup 日志文件条目

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

下面的示例显示了一个 CloudTrail 日志条目,该条目演示了StartBackupJobStartRestoreJob, 和DeleteRecoveryPoint操作以及BackupJobCompletedevent.

{ "eventVersion": "1.05", "userIdentity": { "type": "Root", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "account-id", "accessKeyId": aceess-key, "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-01-10T12:24:50Z" } } }, "eventTime": "2019-01-10T13:45:24Z", "eventSource": "backup.amazonaws.com", "eventName": "StartBackupJob", "awsRegion": "us-east-1", "sourceIPAddress": "12.34.567.89", "userAgent": "aws-internal/3 aws-sdk-java/1.11.465 Linux/4.9.124-0.1.ac.198.73.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.192-b12 java/1.8.0_192", "requestParameters": { "backupVaultName": "Default", "resourceArn": "arn:aws:ec2:us-east-1:123456789012:volume/vol-00a422a05b9c6asd3", "iamRoleArn": "arn:aws:iam::123456789012:role/AWSBackup", "startWindowMinutes": 60 }, "responseElements": { "backupJobId": "8a3c2a87-b23e-4d56-b045-fa9e88ede4e6", "creationDate": "Jan 10, 2019 1:45:24 PM" }, "requestID": "98cf4d59-8c76-49f7-9201-790743931234", "eventID": "fe8146a5-7812-4a95-90ad-074498be1234", "eventType": "AwsApiCall", "recipientAccountId": "account-id" }, { "eventVersion": "1.05", "userIdentity": { "type": "Root", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "account-id", "accessKeyId": "access-key", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-01-10T12:24:50Z" } } }, "eventTime": "2019-01-10T13:49:50Z", "eventSource": "backup.amazonaws.com", "eventName": "StartRestoreJob", "awsRegion": "us-east-1", "sourceIPAddress": "12.34.567.89", "userAgent": "aws-internal/3 aws-sdk-java/1.11.465 Linux/4.9.124-0.1.ac.198.73.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.192-b12 java/1.8.0_192", "requestParameters": { "recoveryPointArn": "arn:aws:ec2:us-east-1::snapshot/snap-00a129455bdbc9d99", "metadata": { "volumeType": "gp2", "availabilityZone": "us-east-1b", "volumeSize": "100" }, "iamRoleArn": "arn:aws:iam::123456789012:role/AWSBackup", "idempotencyToken": "a9c8b4fb-d369-4a58-944b-942e442a8fe3", "resourceType": "EBS" }, "responseElements": { "restoreJobId": "9808E090-8C76-CCB8-4CEA-407CF6AC4C43" }, "requestID": "783ddddc-6d7e-4539-8fab-376aa9668543", "eventID": "ff35ddea-7577-4aec-a132-964b7e9dd423", "eventType": "AwsApiCall", "recipientAccountId": "account-id" }, { "eventVersion": "1.05", "userIdentity": { "type": "Root", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "account-id", "accessKeyId": "access-key", "sessionContext": { "attributes": { "mfaAuthenticated": "false", "creationDate": "2019-01-10T12:24:50Z" } } }, "eventTime": "2019-01-10T14:52:42Z", "eventSource": "backup.amazonaws.com", "eventName": "DeleteRecoveryPoint", "awsRegion": "us-east-1", "sourceIPAddress": "12.34.567.89", "userAgent": "aws-internal/3 aws-sdk-java/1.11.465 Linux/4.9.124-0.1.ac.198.73.329.metal1.x86_64 OpenJDK_64-Bit_Server_VM/25.192-b12 java/1.8.0_192", "requestParameters": { "backupVaultName": "Default", "recoveryPointArn": "arn:aws:ec2:us-east-1::snapshot/snap-05f426fd9daab3433" }, "responseElements": null, "requestID": "f1f1b33a-48da-436c-9a8f-7574f1ab5fd7", "eventID": "2dd70080-5aba-4a79-9a0f-92647c9f0846", "eventType": "AwsApiCall", "recipientAccountId": "account-id" }, { "eventVersion": "1.05", "userIdentity": { "accountId": "account-id", "invokedBy": "backup.amazonaws.com" }, "eventTime": "2019-01-10T08:24:39Z", "eventSource": "backup.amazonaws.com", "eventName": "BackupJobCompleted", "awsRegion": "us-east-1", "sourceIPAddress": "backup.amazonaws.com", "userAgent": "backup.amazonaws.com", "requestParameters": null, "responseElements": null, "eventID": "2e7e4fcf-0c52-467f-9fd0-f61c2fcf7d17", "eventType": "AwsServiceEvent", "recipientAccountId": "account-id", "serviceEventDetails": { "completionDate": { "seconds": 1547108091, "nanos": 906000000 }, "state": "COMPLETED", "percentDone": 100, "backupJobId": "8A8E738B-A8C5-E058-8224-90FA323A3C0E", "backupVaultName": "BackupVault", "backupVaultArn": "arn:aws:backup:us-east-1:123456789012:backup-vault:BackupVault", "recoveryPointArn": "arn:aws:ec2:us-east-1::snapshot/snap-07ce8c3141d361233", "resourceArn": "arn:aws:ec2:us-east-1:123456789012:volume/vol-06692095a6a421233", "creationDate": { "seconds": 1547101638, "nanos": 272000000 }, "backupSizeInBytes": 8589934592, "iamRoleArn": "arn:aws:iam::123456789012:role/AWSBackup", "resourceType": "EBS" } }

记录跨账户管理事件

使用 AWS Backup,您可以跨中的所有 AWS 账户管理备份。AWS Organizations结构。当您创建、更新或删除 AWS Organizations 备份策略(将备份计划应用于您的成员账户)时,AWS Backup 将生成这些 CloudTrail 事件:

  • CreateOrganizationalBackupPlan

  • UpdateOrganizationalBackupPlan

  • DeleteOrganizationalBackupPlan

例如:用于跨账户管理的 AWS Backup 日志文件条目

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

下面的示例显示了一个 CloudTrail 日志条目,该条目说明了 CreateOrganizationalBackupPlan 操作。

{ "*eventVersion*": "1.05", "*userIdentity*": { "*accountId*": "account-id", "*invokedBy*": "backup.amazonaws.com"}, "*eventTime*": "2020-06-02T00:34:00Z", "*eventSource*": "backup.amazonaws.com", "*eventName*": "CreateOrganizationalBackupPlan", "*awsRegion*": "ca-central-1", "*sourceIPAddress*": "backup.amazonaws.com", "*userAgent*": "backup.amazonaws.com", "*requestParameters*": null, "*responseElements*": null, "*eventID*": "f2642255-af77-4203-8c37-7ca19d898e84", "*readOnly*": false, "*eventType*": "AwsServiceEvent", "*recipientAccountId*": "account-id", "*serviceEventDetails*": { "*backupPlanId*": "orgs/544033d1-b19c-3f2a-9c20-40bcfa82ca68", "*backupPlanVersionId*": "ZTA1Y2ZjZDYtNmRjMy00ZTA1LWIyNTAtM2M1NzQ4OThmNzRj", "*backupPlanArn*": "arn:aws:backup:ca-central-1:123456789012:backup-plan:orgs/544033d1-b19c-3f2a-9c20-40bcfa82ca68", "*backupPlanName*": "mybackupplan", "*backupRules*": "[{\"id\":\"745fd0ea-7f57-3f35-8a0e-ed4b8c48a8e2\",\"name\":\"hourly\",\"description\":null,\"cryopodArn\":\"arn:aws:backup:ca-central-1:123456789012:backup-vault:CryoControllerCAMTestBackupVault\",\"scheduleExpression\":\"cron(0 0/1 ? * * *)\",\"startWindow\":\"PT1H\",\"completionWindow\":\"PT2H\",\"lifecycle\":{\"moveToColdStorageAfterDays\":null,\"deleteAfterDays\":\"7\"},\"tags\":null,\"copyActions\":[]}]", "*backupSelections*": "[{\"name\":\"selectiondatatype\",\"arn\":\"arn:aws:backup:ca-central-1:123456789012:selection:8b40c6d9-3641-3d49-926d-a075ea715686\",\"role\":\"arn:aws:iam::123456789012:role/OrganizationmyRoleTestRole\",\"resources\":[],\"notResources\":[],\"conditions\":[{\"type\":\"STRINGEQUALS\",\"key\":\"dataType\",\"value\":\"PII\"},{\"type\":\"STRINGEQUALS\",\"key\":\"dataType\",\"value\":\"RED\"}],\"creationDate\":\"2020-06-02T00:34:00.695Z\",\"creatorRequestId\":null}]", "*creationDate*": { "*seconds*": 1591058040, "*nanos*": 695000000 }, "*organizationId*": "org-id", "*accountId*": "account-id" } }

下面的示例显示了一个 CloudTrail 日志条目,该条目说明了 DeleteOrganizationalBackupPlan 操作。

{ "*eventVersion*": "1.05", "*userIdentity*": { "*accountId*": "account-id", "*invokedBy*": "backup.amazonaws.com" }, "*eventTime*": "2020-06-02T00:34:25Z", "*eventSource*": "backup.amazonaws.com", "*eventName*": "DeleteOrganizationalBackupPlan", "*awsRegion*": "ca-central-1", "*sourceIPAddress*": "backup.amazonaws.com", "*userAgent*": "backup.amazonaws.com", "*requestParameters*": null, "*responseElements*": null, "*eventID*": "5ce66cd0-b90c-4957-8e00-96ea1077b4fa", "*readOnly*": false, "*eventType*": "AwsServiceEvent", "*recipientAccountId*": "account-id", "*serviceEventDetails*": { "*backupPlanId*": "orgs/544033d1-b19c-3f2a-9c20-40bcfa82ca68", "*backupPlanVersionId*": "ZTA1Y2ZjZDYtNmRjMy00ZTA1LWIyNTAtM2M1NzQ4OThmNzRj", "*backupPlanArn*": "arn:aws:backup:ca-central-1:123456789012:backup-plan:orgs/544033d1-b19c-3f2a-9c20-40bcfa82ca68", "*backupPlanName*": "mybackupplan", "*deletionDate*": { "*seconds*": 1591058065, "*nanos*": 519000000 }, "*organizationId*": "org-id", "*accountId*": "account-id" } }