Logging Amazon Backup API calls with CloudTrail - Amazon Backup
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Logging Amazon Backup API calls with CloudTrail

Amazon Backup is integrated with Amazon CloudTrail, a service that provides a record of actions taken by a user, role, or an Amazon service in Amazon Backup. CloudTrail captures all API calls for Amazon Backup as events. The calls captured include calls from the Amazon Backup console and code calls to the Amazon Backup API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for Amazon Backup. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine the request that was made to Amazon Backup, the IP address from which the request was made, who made the request, when it was made, and additional details. To learn more about CloudTrail, see the Amazon CloudTrail User Guide.

Important

In accounts logging data read events, S3 buckets with CloudTrail logs enabled need their access logs saved to a different target bucket; if CloudTrail logs are saved in the same bucket they log, an infinite loop forms. This loop can trigger unexpected and unwanted charges.

For more information, see Data events in the CloudTrail User Guide.

Amazon Backup information in CloudTrail

CloudTrail is enabled on your Amazon Web Services account when you create the account. When activity occurs in Amazon Backup, that activity is recorded in a CloudTrail event along with other Amazon service events in Event history. You can view, search, and download recent events in your Amazon Web Services account. Amazon Backup generates these CloudTrail events when it performs backups, restores, copies, or notifications:

  • BackupDeleted

  • BackupJobCompleted

  • BackupJobStarted

  • BackupSelectionDeletedDueToSLRDeletion

  • BackupTransitionedToCold

  • CopyJobCompleted

  • CopyJobStarted

  • ReportJobCompleted

  • ReportJobStarted

  • RestoreCompleted

  • RestoreStarted

  • PutBackupVaultNotifications

These events are not necessarily generated by use of the Amazon Backup public APIs. Rather, they are generated through Amazon Backup asynchronously executing your jobs. For example, your StartBackupJob API call could generate the BackupJobStarted event, but a scheduled job from a backup plan could also generate the BackupJobStarted event.

For more information, see Viewing Events with CloudTrail Event History.

For an ongoing record of events in your Amazon Web Services account, including events for Amazon Backup, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all Amazon Regions. The trail logs events from all Regions in the Amazon partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other Amazon services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see the following:

Every event or log entry contains information about who generated the request. The identity information helps you determine the following:

  • Whether the request was made with root or Amazon Identity and Access Management (IAM) user credentials.

  • Whether the request was made with temporary security credentials for a role or federated user.

  • Whether the request was made by another Amazon service.

For more information, see the CloudTrail userIdentity Element.

Understanding Amazon Backup log file entries

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the StartBackupJob, StartRestoreJob, and DeleteRecoveryPoint actions and also the BackupJobCompleted event.

{ "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" } }

Logging cross-account management events

With Amazon Backup, you can manage your backups across all Amazon Web Services accounts inside your Amazon Organizations structure. Amazon Backup generates these CloudTrail events when you create, update, or delete an Amazon Organizations backup policy (that applies backup plans to your member accounts) or when there is an invalid organizational backup plan:

  • CreateOrganizationalBackupPlan

  • UpdateOrganizationalBackupPlan

  • DeleteOrganizationalBackupPlan

  • InvalidOrganizationalBackupPlan

Example: Amazon Backup log file entries for cross-account management

A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the CreateOrganizationalBackupPlan action.

{ "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" } }

The following example shows a CloudTrail log entry that demonstrates the DeleteOrganizationalBackupPlan action.

{ "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" } }

The following example shows a CloudTrail log entry that demonstrates the event InvalidOrganizationBackupPlan, which is sent when Amazon Backup receives an invalid backup plan from Organizations.

{ "eventVersion": "1.08", "userIdentity": { "accountId": "123456789012", "invokedBy": "backup.amazonaws.com" }, "eventTime": "2022-06-11T13:29:23Z", "eventSource": "backup.amazonaws.com", "eventName": "InvalidOrganizationBackupPlan", "awsRegion": "Region", "sourceIPAddress": "backup.amazonaws.com", "userAgent": "backup.amazonaws.com", "requestParameters": null, "responseElements": null, "eventID": "ab1de234-fg56-7890-h123-45ij678k9l01", "readOnly": false, "eventType": "AwsServiceEvent", "managementEvent": true, "recipientAccountId": "987654321098", "serviceEventDetails": { "effectivePolicyVersion": 7, "effectivePolicyId": "12345678-a9b0-123c-45d6-78e901f23456", "lastUpdatedTimestamp": "Jun 11, 2022 1:29:22 PM", "policyType": "BACKUP_POLICY", "effectiveBackupPlan": { "logicalName": "logical-name", "regions": [ "Region" ], "rules": [ { "name": "test-orgs", "targetBackupVaultName": "vault-name", "ruleLifecycle": { "deleteAfterDays": 100 }, "copyActions": [], "enableContinuousBackup": true } ], "selections": { "tagSelections": [ { "selectionName": "selection-name", "iamRoleArn": "arn:aws:iam::$account:role/role", "targetedTags": [ { "tagKey": "key", "tagValue": "value" } ] } ] }, "backupPlanTags": { "key": "value" } }, "organizationId": "org-id", "accountId": "account-id" }, "eventCategory": "Management" }