Logging Amazon Directory Service API Calls with CloudTrail - Amazon Directory Service
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 Directory Service API Calls with CloudTrail

The Amazon Directory Service API is integrated with Amazon CloudTrail, a service that captures API calls made by or on behalf of Amazon Directory Service in your Amazon Web Services account and delivers the log files to an Amazon S3 bucket that you specify. CloudTrail captures API calls from the Amazon Directory Service console and from code calls to the Amazon Directory Service APIs. Using the information collected by CloudTrail, you can determine what request was made to Amazon Directory Service, the source IP address from which the request was made, who made the request, when it was made, and so on. To learn more about CloudTrail, see the Amazon CloudTrail User Guide.

Amazon Directory Service Information in CloudTrail

CloudTrail is enabled on your Amazon Web Services account when you create the account. When activity occurs in Amazon Directory Service, 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. 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 Directory Service, 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:

When CloudTrail logging is enabled in your Amazon Web Services account, all API calls made to Amazon Directory Service actions are tracked in log files. Amazon Directory Service records are written together with other Amazon service records in a log file. CloudTrail determines when to create and write to a new file based on a time period and file size. All calls made to the Amazon Directory Service API or CLI calls are logged by CloudTrail.

Every log entry contains information about who generated the request. The user identity information in the log helps you determine whether the request was made with root or IAM user credentials, with temporary security credentials for a role or federated user, or by another Amazon service. For more information, see the userIdentity field in the CloudTrail Event Reference.

You can store your log files in your bucket for as long as you want, but you can also define Amazon S3 lifecycle rules to archive or delete log files automatically. By default, your log files are encrypted by using Amazon S3 server-side encryption (SSE).

You can choose to have CloudTrail publish Amazon SNS notifications when new log files are delivered if you want to take quick action upon log file delivery. For more information, see Configuring Amazon SNS Notifications.

You can also aggregate Amazon Directory Service log files from multiple Amazon Regions and Amazon Web Services accounts into a single Amazon S3 bucket. For more information, see Aggregating CloudTrail Log Files to a Single Amazon S3 Bucket.

Understanding Amazon Directory Service Log File Entries

CloudTrail log files can contain one or more log entries, where each entry is made up of multiple JSON-formatted events. A log entry represents a single request from any source and includes information about the requested action, any parameters, the date and time of the action, and so on. The log entries are not guaranteed to be in any particular order; that is, they are not an ordered stack trace of the public API calls.

Sensitive information, such as passwords, authentication tokens, file comments, and file contents are redacted in the log entries.

The following example shows an example of a CloudTrail log entry for Amazon Directory Service:

{ "Records" : [ { "eventVersion" : "1.02", "userIdentity" : { "type" : "IAMUser", "principalId" : "<user_id>", "arn" : "<user_arn>", "accountId" : "<account_id>", "accessKeyId" : "<access_key_id>", "userName" : "<username>" }, "eventTime" : "<event_time>", "eventSource" : "ds.amazonaws.com", "eventName" : "CreateDirectory", "awsRegion" : "<region>", "sourceIPAddress" : "<IP_address>", "userAgent" : "<user_agent>", "requestParameters" : { "name" : "<name>", "shortName" : "<short_name>", "vpcSettings" : { "vpcId" : "<vpc_id>", "subnetIds" : [ "<subnet_id_1>", "<subnet_id_2>" ] }, "type" : "<size>", "setAsDefault" : <option>, "password" : "***OMITTED***" }, "responseElements" : { "requestId" : "<request_id>", "directoryId" : "<directory_id>" }, "requestID" : "<request_id>", "eventID" : "<event_id>", "eventType" : "AwsApiCall", "recipientAccountId" : "<account_id>" } ] }