Logging Amazon Macie API calls using AWS CloudTrail - Amazon Macie

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 Macie console and code calls to 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 view the most recent events by using Event history on the 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.

Macie information in CloudTrail

CloudTrail is enabled for your Amazon Web Services account when you create the account. When activity occurs in Macie, that activity is recorded in a CloudTrail event along with other Amazon Web Services events in Event history. You can view, search, and download recent events in your Amazon Web Services account. 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 Macie, create a trail. A trail enables CloudTrail to deliver log files to an S3 bucket. By default, when you create a trail in the 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 ListFindings and CreateFindingsFilter actions generate entries in the 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 the CloudTrail userIdentity element.

Understanding Macie log file entries

A trail is a configuration that enables delivery of events as log files to an 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 ListFindings action.

{ "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:user/Mary", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "Mary", }, "eventTime": "2020-05-22T16:09:56Z", "eventSource": "macie2.amazonaws.com", "eventName": "ListFindings", "awsRegion": "us-east-1", "sourceIPAddress": "", "userAgent": "console.amazonaws.com", "requestParameters": { "sortCriteria": { "attributeName": "updatedAt", "orderBy": "DESC" }, "findingCriteria": { "criterion": { "archived": { "eq": [ "false" ] }, "category": { "eq": [ "POLICY" ] } } }, "maxResults": 10 }, "responseElements": null, "requestID": "d58af6be-1115-4a41-91f8-ace03example", "eventID": "ad97fac5-f7cf-4ff9-9cf2-d0676example", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }