Logging Amazon Macie API calls using AWS CloudTrail

Amazon Macie integrates with AWS CloudTrail, which is a service that provides a record of actions that were taken in Macie by a user, a role, or another AWS service. CloudTrail captures all API calls for Macie as events. The calls captured include calls from the Amazon Macie console and programmatic calls to Amazon Macie API operations.

If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon Simple Storage Service (Amazon S3) bucket, including events for Macie. If you don't configure a trail, you can still review the most recent events by using Event history on the AWS CloudTrail console. Using the information collected by CloudTrail, you can determine the request that was made to Macie, 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 AWS CloudTrail User Guide.

Amazon Macie information in AWS CloudTrail

AWS CloudTrail is enabled for your AWS account when you create the account. When activity occurs in Amazon Macie, that activity is recorded in a CloudTrail event along with other AWS events in Event history. You can review, search, and download recent events in your AWS account. For more information, see Working with CloudTrail Event history in the AWS CloudTrail User Guide.

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

All Macie actions are logged by CloudTrail and are documented in the Amazon Macie API Reference. For example, calls to the CreateClassificationJob, DescribeBuckets, and ListFindings actions generate entries in CloudTrail log files.

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 AWS 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 AWS service.

For more information, see CloudTrail userIdentity element in the AWS CloudTrail User Guide.

Understanding Amazon Macie log file entries

A trail is a configuration that enables delivery of events as log files to an Amazon Simple Storage Service (Amazon S3) bucket that you specify. 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. AWS CloudTrail log files contain one or more log entries for events. 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 examples show CloudTrail log entries that demonstrate events for Amazon Macie actions. For details about the information that a log entry might contain, see CloudTrail log event reference in the AWS CloudTrail User Guide.

Example: Listing findings

The following example shows a CloudTrail log entry that demonstrates an event for the Macie ListFindings action. In this example, an AWS Identity and Access Management (IAM) user (Mary_Major) used the Amazon Macie console to retrieve a subset of information about current policy findings for their account.

{ "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": "2023-11-14T15:49:57Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-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" }
Example: Retrieving sensitive data samples for a finding

This example shows CloudTrail log entries that demonstrate events for retrieving and revealing samples of sensitive data that Macie reported in a finding. In this example, an IAM user (JohnDoe) used the Amazon Macie console to retrieve and reveal sensitive data samples. The user's Macie account is configured to assume an IAM role (MacieReveal) to retrieve and reveal sensitive data samples.

The following log event shows details about the user's request to retrieve and reveal sensitive data samples by performing the Macie GetSensitiveDataOccurrences action.

{ "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": "2023-12-12T14:40:23Z", "mfaAuthenticated": "false" } } }, "eventTime": "2023-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" }

The next log event shows details about Macie then assuming the specified IAM role (MacieReveal) by performing the AWS Security Token Service (AWS STS) AssumeRole action.

{ "eventVersion": "1.08", "userIdentity": { "type": "AWSService", "invokedBy": "reveal-samples.macie.amazonaws.com" }, "eventTime": "2023-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, 2023, 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" }