View a markdown version of this page

Logging data events - Amazon CloudTrail
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 data events

This section describes how to log data events using the CloudTrail console and Amazon CLI.

By default, trails and event data stores do not log data events. Additional charges apply for data events. For more information, see Amazon CloudTrail Pricing.

Data events provide information about the resource operations performed on or in a resource. These are also known as data plane operations. Data events are often high-volume activities.

Example data events include:

You can use advanced event selectors to create fine-grained selectors, which help you control costs by only logging the specific events of interest for your use cases. For example, you can use advanced event selectors to log specific API calls by adding a filter on the eventName field. For more information, see Filtering data events by using advanced event selectors.

Note

The events that are logged by your trails are available in Amazon EventBridge. For example, if you choose to log data events for S3 objects but not management events, your trail processes and logs only data events for the specified S3 objects. The data events for these S3 objects are available in Amazon EventBridge. For more information, see Amazon service events delivered via CloudTrail in the Amazon EventBridge User Guide and the Amazon Events Reference.

Contents

Data events

The following table shows the resource types available for trails. The Resource type (console) column shows the appropriate selection in the console. The resources.type value column shows the resources.type value that you would specify to include data events of that type in your trail using the Amazon CLI or CloudTrail APIs.

For trails, you can use basic or advanced event selectors to log data events for Amazon S3 objects in general purpose buckets, Lambda functions, and DynamoDB tables (shown in the first three rows of the table). You can use only advanced event selectors to log the resource types shown in the remaining rows.

Data events supported by Amazon CloudTrail

Amazon Web Services service Description Resource type (console) resources.type value

Amazon AppConfig

Amazon AppConfig API activity for configuration operations such as calls to StartConfigurationSession and GetLatestConfiguration. For more information, see Amazon AppConfig.

Amazon AppConfig

AWS::AppConfig::Configuration

Amazon AppSync

Amazon AppSync API activity on AppSync GraphQL APIs. For more information, see Amazon AppSync.

AppSync GraphQL

AWS::AppSync::GraphQLApi

Amazon Bedrock

Amazon Bedrock APIKey CredentialProvider API activity.

Bedrock-AgentCore APIKey CredentialProvider

AWS::BedrockAgentCore::APIKeyCredentialProvider

Amazon Bedrock

Amazon Bedrock Browser API activity.

Bedrock-AgentCore Browser

AWS::BedrockAgentCore::Browser

Amazon Bedrock

Amazon Bedrock Browser-Custom API activity.

Bedrock-AgentCore Browser-Custom

AWS::BedrockAgentCore::BrowserCustom

Bedrock-AgentCore Browser Profile

API activity on AWS::BedrockAgentCore::BrowserProfile resources.

Bedrock-AgentCore Browser Profile

AWS::BedrockAgentCore::BrowserProfile

Amazon Bedrock

Amazon Bedrock Code-Interpreter API activity.

Bedrock-AgentCore Code-Interpreter

AWS::BedrockAgentCore::CodeInterpreter

Amazon Bedrock

Amazon Bedrock Code-Interpreter-Custom API activity.

Bedrock-AgentCore Code-Interpreter-Custom

AWS::BedrockAgentCore::CodeInterpreterCustom

Amazon Bedrock

Amazon Bedrock Gateway API activity.

Bedrock-AgentCore Gateway

AWS::BedrockAgentCore::Gateway

Amazon Bedrock

Amazon Bedrock Oauth2 CredentialProvider API activity.

Bedrock-AgentCore Oauth2 CredentialProvider

AWS::BedrockAgentCore::OAuth2CredentialProvider

Amazon Bedrock

Amazon Bedrock Runtime API activity.

Bedrock-AgentCore Runtime

AWS::BedrockAgentCore::Runtime

Amazon Bedrock

Amazon Bedrock Runtime-Endpoint API activity.

Bedrock-AgentCore Runtime-Endpoint

AWS::BedrockAgentCore::RuntimeEndpoint

Amazon Bedrock

Amazon Bedrock Token Vault API activity.

Bedrock-AgentCore Token Vault

AWS::BedrockAgentCore::TokenVault

Amazon Bedrock

Amazon Bedrock Workload Identity API activity.

Bedrock-AgentCore Workload Identity

AWS::BedrockAgentCore::WorkloadIdentity

Amazon Bedrock

Amazon Bedrock Workload Identity Directory API activity.

Bedrock-AgentCore Workload Identity Directory

AWS::BedrockAgentCore::WorkloadIdentityDirectory

Amazon Keyspaces (for Apache Cassandra)

Amazon Keyspaces (for Apache Cassandra) API activity on Cassandra CDC streams.

Cassandra CDC streams

AWS::Cassandra::Stream

Amazon Keyspaces (for Apache Cassandra)

Amazon Keyspaces API activity on a table. For more information, see Amazon Keyspaces (for Apache Cassandra).

Cassandra table

AWS::Cassandra::Table

Amazon CloudWatch

Amazon CloudWatch API activity on metrics. For more information, see Amazon CloudWatch.

CloudWatch metric

AWS::CloudWatch::Metric

Amazon Cognito

Amazon Cognito API activity on Amazon Cognito identity pools. For more information, see Amazon Cognito.

Cognito Identity Pools

AWS::Cognito::IdentityPool

Amazon DynamoDB

Amazon DynamoDB API activity on streams. For more information, see Amazon DynamoDB.

DynamoDB Streams

AWS::DynamoDB::Stream

Amazon DynamoDB

Amazon DynamoDB item-level API activity on tables (for example, PutItem, DeleteItem, and UpdateItem API operations). For tables with streams enabled, the resources field in the data event contains both Amazon::DynamoDB::Stream and Amazon::DynamoDB::Table. If you specify Amazon::DynamoDB::Table for the resources.type, it will log both DynamoDB table and DynamoDB streams events by default. To exclude streams events, add a filter on the eventName field. For more information, see Amazon DynamoDB.

DynamoDB

AWS::DynamoDB::Table

Amazon Elastic Block Store

Amazon Elastic Block Store (EBS) direct APIs, such as PutSnapshotBlock, GetSnapshotBlock, and ListChangedBlocks on Amazon EBS snapshots. For more information, see Amazon Elastic Block Store.

EBS direct APIs

AWS::EC2::Snapshot

Amazon Elastic Container Service

Amazon Elastic Container Service API activity on a container instance.

ECS container instance

AWS::ECS::ContainerInstance

Amazon Elastic Kubernetes Service

Amazon Elastic Kubernetes Service API activity on dashboards.

EKS dashboard

AWS::EKS::Dashboard

EventBridge endpoint

API activity on AWS::Events::Endpoint resources.

EventBridge endpoint

AWS::Events::Endpoint

EventBridge event bus

API activity on AWS::Events::EventBus resources.

EventBridge event bus

AWS::Events::EventBus

EventBridge partner event source

API activity on AWS::Events::EventSource resources.

EventBridge partner event source

AWS::Events::EventSource

EventBridge rule

API activity on AWS::Events::Rule resources.

EventBridge rule

AWS::Events::Rule

Amazon FSx

Amazon FSx API activity on volumes.

FSx Volume

AWS::FSx::Volume

Amazon IoT Greengrass Version 2

Greengrass API activity from a Greengrass core device on a component version. Greengrass doesn't log access denied events. For more information, see Amazon IoT Greengrass Version 2.

IoT Greengrass component version

AWS::GreengrassV2::ComponentVersion

Amazon IoT Greengrass Version 2

Greengrass API activity from a Greengrass core device on a deployment. Greengrass doesn't log access denied events. For more information, see Amazon IoT Greengrass Version 2.

IoT Greengrass deployment

AWS::GreengrassV2::Deployment

Amazon GuardDuty

GuardDuty API activity on malware scans.

GuardDuty malware scan

AWS::GuardDuty::MalwareScan

Amazon IoT

Amazon IoT API activity on certificates. For more information, see Amazon IoT.

IoT certificate

AWS::IoT::Certificate

Amazon IoT

Amazon IoT API activity on things. For more information, see Amazon IoT.

IoT thing

AWS::IoT::Thing

Amazon IoT tunnel

API activity on AWS::IoT::Tunnel resources.

Amazon IoT tunnel

AWS::IoT::Tunnel

Amazon IoT SiteWise

IoT SiteWise API activity on assets. For more information, see Amazon IoT SiteWise.

IoT SiteWise asset

AWS::IoTSiteWise::Asset

Amazon IoT SiteWise

IoT SiteWise API activity on time series. For more information, see Amazon IoT SiteWise.

IoT SiteWise time series

AWS::IoTSiteWise::TimeSeries

Amazon IoT TwinMaker

IoT TwinMaker API activity on an entity. For more information, see Amazon IoT TwinMaker.

IoT TwinMaker entity

AWS::IoTTwinMaker::Entity

Amazon IoT TwinMaker

IoT TwinMaker API activity on a workspace. For more information, see Amazon IoT TwinMaker.

IoT TwinMaker workspace

AWS::IoTTwinMaker::Workspace

Amazon Kinesis Data Streams

Kinesis Data Streams API activity on streams. For more information, see Amazon Kinesis Data Streams.

Kinesis stream

AWS::Kinesis::Stream

Amazon Kinesis Data Streams

Kinesis Data Streams API activity on stream consumers. For more information, see Amazon Kinesis Data Streams.

Kinesis stream consumer

AWS::Kinesis::StreamConsumer

Amazon Data Firehose

Amazon Data Firehose delivery stream API activity.

Amazon Data Firehose

AWS::KinesisFirehose::DeliveryStream

Amazon Lambda

Amazon Lambda function execution activity (the Invoke API).

Lambda

AWS::Lambda::Function

Amazon Managed Workflows for Apache Airflow

Amazon MWAA API activity on environments.

Managed Apache Airflow

AWS::MWAA::Environment

Amazon Redshift

Redshift API activity on clusters.

Redshift Cluster

AWS::Redshift::Cluster

Amazon S3

Amazon S3 API activity on access points. For more information, see Amazon S3.

S3 Access Point

AWS::S3::AccessPoint

Amazon S3

Amazon S3 object-level API activity (for example, GetObject, DeleteObject, and PutObject API operations) on objects in general purpose buckets. For more information, see Amazon S3.

S3

AWS::S3::Object

S3 Express Access Point

API activity on AWS::S3Express::AccessPoint resources.

S3 Express Access Point

AWS::S3Express::AccessPoint

Amazon S3

Amazon S3 object-level API activity (for example, GetObject, DeleteObject, and PutObject API operations) on objects in directory buckets. For more information, see Amazon S3.

S3 Express

AWS::S3Express::Object

Amazon S3

Amazon S3 Object Lambda access points API activity, such as calls to CompleteMultipartUpload and GetObject. For more information, see Amazon S3.

S3 Object Lambda

AWS::S3ObjectLambda::AccessPoint

Amazon S3 Tables

Amazon S3 API activity on tables. For more information, see Amazon S3 Tables.

S3 table

AWS::S3Tables::Table

Amazon S3 Tables

Amazon S3 API activity on table buckets. For more information, see Amazon S3 Tables.

S3 table bucket

AWS::S3Tables::TableBucket

Amazon S3 Vectors

Amazon S3 API activity on vector indexes. For more information, see Amazon S3 Vectors.

S3 vector index

AWS::S3Vectors::Index

Amazon S3 Vectors

Amazon S3 API activity on vector buckets. For more information, see Amazon S3 Vectors.

S3 vector bucket

AWS::S3Vectors::VectorBucket

Amazon SageMaker AI

Amazon SageMaker AI InvokeEndpointWithResponseStream activity on endpoints. For more information, see Amazon SageMaker AI.

SageMaker endpoint

AWS::SageMaker::Endpoint

Amazon SageMaker AI

Amazon SageMaker AI API activity on feature stores.

SageMaker Feature Store

AWS::SageMaker::FeatureGroup

Amazon Cloud Map

Amazon Cloud Map API activity on a namespace. For more information, see Amazon Cloud Map.

Amazon Cloud Map namespace

AWS::ServiceDiscovery::Namespace

Amazon Cloud Map

Amazon Cloud Map API activity on a service. For more information, see Amazon Cloud Map.

Amazon Cloud Map service

AWS::ServiceDiscovery::Service

Amazon SNS

Amazon SNS Publish API operations on platform endpoints. For more information, see Amazon SNS.

SNS platform endpoint

AWS::SNS::PlatformEndpoint

Amazon SNS

Amazon SNS Publish and PublishBatch API operations on topics. For more information, see Amazon SNS.

SNS topic

AWS::SNS::Topic

Amazon SQS

Amazon SQS API activity on messages. For more information, see Amazon SQS.

SQS

AWS::SQS::Queue

Amazon Systems Manager

Systems Manager API activity on managed nodes. For more information, see Amazon Systems Manager.

Systems Manager managed node

AWS::SSM::ManagedNode

Amazon Systems Manager

Systems Manager API activity on control channels. For more information, see Amazon Systems Manager.

Systems Manager

AWS::SSMMessages::ControlChannel

Amazon Step Functions

Step Functions API activity on activities. For more information, see Amazon Step Functions.

Step Functions activity

AWS::StepFunctions::Activity

Amazon Step Functions

Step Functions API activity on state machines. For more information, see Amazon Step Functions.

Step Functions state machine

AWS::StepFunctions::StateMachine

Amazon SWF

Amazon SWF API activity on domains. For more information, see Amazon SWF.

SWF domain

AWS::SWF::Domain

Amazon Verified Permissions

Amazon Verified Permissions API activity on a policy store.

Amazon Verified Permissions

AWS::VerifiedPermissions::PolicyStore

Amazon X-Ray

X-Ray API activity on traces. For more information, see Amazon X-Ray.

X-Ray trace

AWS::XRay::Trace

To record CloudTrail data events, you must explicitly add each resource type for which you want to collect activity. For more information, see Creating a trail with the CloudTrail console and Create an event data store for CloudTrail events with the console.

On a single-Region trail or event data store, you can log data events only for resources that you can access in that Region. Though S3 buckets are global, Amazon Lambda functions and DynamoDB tables are regional.

Additional charges apply for logging data events. For CloudTrail pricing, see Amazon CloudTrail Pricing.

Examples: Logging data events for Amazon S3 objects

Logging data events for all S3 objects in an S3 bucket

The following example demonstrates how logging works when you configure logging of all data events for an S3 bucket named amzn-s3-demo-bucket. In this example, the CloudTrail user specified an empty prefix, and the option to log both Read and Write data events.

  1. A user uploads an object to amzn-s3-demo-bucket.

  2. The PutObject API operation is an Amazon S3 object-level API. It is recorded as a data event in CloudTrail. Because the CloudTrail user specified an S3 bucket with an empty prefix, events that occur on any object in that bucket are logged. The trail or event data store processes and logs the event.

  3. Another user uploads an object to amzn-s3-demo-bucket2.

  4. The PutObject API operation occurred on an object in an S3 bucket that wasn't specified for the trail or event data store. The trail or event data store doesn't log the event.

Logging data events for specific S3 objects

The following example demonstrates how logging works when you configure a trail or event data store to log events for specific S3 objects. In this example, the CloudTrail user specified an S3 bucket named amzn-s3-demo-bucket3, with the prefix my-images, and the option to log only Write data events.

  1. A user deletes an object that begins with the my-images prefix in the bucket, such as arn:aws:s3:::amzn-s3-demo-bucket3/my-images/example.jpg.

  2. The DeleteObject API operation is an Amazon S3 object-level API. It is recorded as a Write data event in CloudTrail. The event occurred on an object that matches the S3 bucket and prefix specified in the trail or event data store. The trail or event data store processes and logs the event.

  3. Another user deletes an object with a different prefix in the S3 bucket, such as arn:aws:s3:::amzn-s3-demo-bucket3/my-videos/example.avi.

  4. The event occurred on an object that doesn't match the prefix specified in your trail or event data store. The trail or event data store doesn't log the event.

  5. A user calls the GetObject API operation for the object, arn:aws:s3:::amzn-s3-demo-bucket3/my-images/example.jpg.

  6. The event occurred on a bucket and prefix that are specified in the trail or event data store, but GetObject is a read-type Amazon S3 object-level API. It is recorded as a Read data event in CloudTrail, and the trail or event data store is not configured to log Read events. The trail or event data store doesn't log the event.

Note

For trails, if you are logging data events for specific Amazon S3 buckets, we recommend you do not use an Amazon S3 bucket for which you are logging data events to receive log files that you have specified in the data events section for your trail. Using the same Amazon S3 bucket causes your trail to log a data event each time log files are delivered to your Amazon S3 bucket. Log files are aggregated events delivered at intervals, so this is not a 1:1 ratio of event to log file; the event is logged in the next log file. For example, when CloudTrail delivers logs, the PutObject event occurs on the S3 bucket. If the S3 bucket is also specified in the data events section, the trail processes and logs the PutObject event as a data event. That action is another PutObject event, and the trail processes and logs the event again.

To avoid logging data events for the Amazon S3 bucket where you receive log files if you configure a trail to log all Amazon S3 data events in your Amazon account, consider one of the following options:

Logging data events for S3 objects in other Amazon accounts

When you configure your trail to log data events, you can also specify S3 objects that belong to other Amazon accounts. When an event occurs on a specified object, CloudTrail evaluates whether the event matches any trails in each account. If the event matches the settings for a trail, the trail processes and logs the event for that account. Generally, both API callers and resource owners can receive events.

If you own an S3 object and you specify it in your trail, your trail logs events that occur on the object in your account. Because you own the object, your trail also logs events when other accounts call the object.

If you specify an S3 object in your trail, and another account owns the object, your trail only logs events that occur on that object in your account. Your trail doesn't log events that occur in other accounts.

Example: Logging data events for an Amazon S3 object for two Amazon accounts

The following example shows how two Amazon accounts configure CloudTrail to log events for the same S3 object.

  1. In your account, you want your trail to log data events for all objects in your S3 bucket named amzn-s3-demo-bucket. You configure the trail by specifying the S3 bucket with an empty object prefix.

  2. Bob has a separate account that has been granted access to the S3 bucket. Bob also wants to log data events for all objects in the same S3 bucket. For his trail, he configures his trail and specifies the same S3 bucket with an empty object prefix.

  3. Bob uploads an object to the S3 bucket with the PutObject API operation.

  4. This event occurred in his account and it matches the settings for his trail. Bob's trail processes and logs the event.

  5. Because you own the S3 bucket and the event matches the settings for your trail, your trail also processes and logs the same event. Because there are now two copies of the event (one logged in Bob's trail, and one logged in yours), CloudTrail charges for two copies of the data event.

  6. You upload an object to the S3 bucket.

  7. This event occurs in your account and it matches the settings for your trail. Your trail processes and logs the event.

  8. Because the event didn't occur in Bob's account, and he doesn't own the S3 bucket, Bob's trail doesn't log the event. CloudTrail charges for only one copy of this data event.

Example: Logging data events for all buckets, including an S3 bucket used by two Amazon accounts

The following example shows the logging behavior when Select all S3 buckets in your account is enabled for trails that collect data events in an Amazon account.

  1. In your account, you want your trail to log data events for all S3 buckets. You configure the trail by choosing Read events, Write events, or both for All current and future S3 buckets in Data events.

  2. Bob has a separate account that has been granted access to an S3 bucket in your account. He wants to log data events for the bucket to which he has access. He configures his trail to get data events for all S3 buckets.

  3. Bob uploads an object to the S3 bucket with the PutObject API operation.

  4. This event occurred in his account and it matches the settings for his trail. Bob's trail processes and logs the event.

  5. Because you own the S3 bucket and the event matches the settings for your trail, your trail also processes and logs the event. Because there are now two copies of the event (one logged in Bob's trail, and one logged in yours), CloudTrail charges each account for a copy of the data event.

  6. You upload an object to the S3 bucket.

  7. This event occurs in your account and it matches the settings for your trail. Your trail processes and logs the event.

  8. Because the event didn't occur in Bob's account, and he doesn't own the S3 bucket, Bob's trail doesn't log the event. CloudTrail charges for only one copy of this data event in your account.

  9. A third user, Mary, has access to the S3 bucket, and runs a GetObject operation on the bucket. She has a trail configured to log data events on all S3 buckets in her account. Because she is the API caller, CloudTrail logs a data event in her trail. Though Bob has access to the bucket, he is not the resource owner, so no event is logged in his trail this time. As the resource owner, you receive an event in your trail about the GetObject operation that Mary called. CloudTrail charges your account and Mary's account for each copy of the data event: one in Mary's trail, and one in yours.

Read-only and write-only events

When you configure your trail or event data store to log data and management events, you can specify whether you want read-only events, write-only events, or both.

  • Read

    Read events include API operations that read your resources, but don't make changes. For example, read-only events include the Amazon EC2 DescribeSecurityGroups and DescribeSubnets API operations. These operations return only information about your Amazon EC2 resources and don't change your configurations.

  • Write

    Write events include API operations that modify (or might modify) your resources. For example, the Amazon EC2 RunInstances and TerminateInstances API operations modify your instances.

Example: Logging read and write events for separate trails

The following example shows how you can configure trails to split log activity for an account into separate S3 buckets: one bucket named amzn-s3-demo-bucket1 receives read-only events and a second amzn-s3-demo-bucket2 receives write-only events.

  1. You create a trail and choose the S3 bucket named amzn-s3-demo-bucket1 to receive log files. You then update the trail to specify that you want Read management events and data events.

  2. You create a second trail and choose the S3 bucket the amzn-s3-demo-bucket2 to receive log files. You then update the trail to specify that you want Write management events and data events.

  3. The Amazon EC2 DescribeInstances and TerminateInstances API operations occur in your account.

  4. The DescribeInstances API operation is a read-only event and it matches the settings for the first trail. The trail logs and delivers the event to the amzn-s3-demo-bucket1.

  5. The TerminateInstances API operation is a write-only event and it matches the settings for the second trail. The trail logs and delivers the event to the amzn-s3-demo-bucket2 .

Logging data events with the Amazon Web Services Management Console

The following procedures describe how to an update existing event data store or trail to log data events by using the Amazon Web Services Management Console. For information about how to create an event data store to log data events, see Create an event data store for CloudTrail events with the console. For information about how to create a trail to log data events, see Creating a trail with the console.

For trails, the steps for logging data events differ based on whether you're using advanced event selectors or basic event selectors. You can log data events for all resource types using advanced event selectors, but if you use basic event selectors you're limited to logging data events for Amazon S3 buckets and bucket objects, Amazon Lambda functions, and Amazon DynamoDB tables.

Use the following procedure to update an existing event data store to log data events. For more information about using advanced event selectors, see Filtering data events by using advanced event selectors in this topic.

  1. Sign in to the Amazon Web Services Management Console and open the CloudTrail console at https://console.amazonaws.cn/cloudtrail/.

  2. From the navigation pane, under Lake, choose Event data stores.

  3. On the Event data stores page, choose the event data store you want to update.

    Note

    You can only enable data events on event data stores that contain CloudTrail events. You cannot enable data events on CloudTrail event data stores for Amazon Config configuration items, CloudTrail Insights events, or non-Amazon events.

  4. On the details page, in Data events, choose Edit.

  5. If you are not already logging data events, choose the Data events check box.

  6. For Resource type, choose the resource type on which you want to log data events.

  7. Choose a log selector template. You can choose a predefined template, or choose Custom to define your own event collection conditions.

    You can choose from the following predefined templates:

    • Log all events – Choose this template to log all events.

    • Log only read events – Choose this template to log only read events. Read-only events are events that do not change the state of a resource, such as Get* or Describe* events.

    • Log only write events – Choose this template to log only write events. Write events add, change, or delete resources, attributes, or artifacts, such as Put*, Delete*, or Write* events.

    • Log only Amazon Web Services Management Console events – Choose this template to log only events originating from the Amazon Web Services Management Console.

    • Exclude Amazon Web Services service initiated events – Choose this template to exclude Amazon Web Services service events, which have an eventType of AwsServiceEvent, and events initiated with Amazon Web Services service-linked roles (SLRs).

  8. (Optional) In Selector name, enter a name to identify your selector. The selector name is a descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets". The selector name is listed as Name in the advanced event selector and is viewable if you expand the JSON view.

  9. If you selected Custom, in Advanced event selectors build an expression based on the values of advanced event selector fields.

    Note

    Selectors don't support the use of wildcards like * . To match multiple values with a single condition, you may use StartsWith, EndsWith, NotStartsWith, or NotEndsWith to explicitly match the beginning or end of the event field.

    1. Choose from the following fields.

      • readOnly - readOnly can be set to equals a value of true or false. Read-only data events are events that do not change the state of a resource, such as Get* or Describe* events. Write events add, change, or delete resources, attributes, or artifacts, such as Put*, Delete*, or Write* events. To log both read and write events, don't add a readOnly selector.

      • eventName - eventName can use any operator. You can use it to include or exclude any data event logged to CloudTrail, such as PutBucket, GetItem, or GetSnapshotBlock.

      • eventSource – The event source to include or exclude. This field can use any operator.

      • eventType – The event type to include or exclude. For example, you can set this field to not equals AwsServiceEvent to exclude Amazon Web Services service events. For a list of event types, see eventType in CloudTrail record contents for management, data, and network activity events.

      • sessionCredentialFromConsole – Include or exclude events originating from an Amazon Web Services Management Console session. This field can be set to equals or not equals with a value of true.

      • userIdentity.arn – Include or exclude events for actions taken by specific IAM identities. For more information, see CloudTrail userIdentity element.

      • resources.ARN - You can use any operator with resources.ARN, but if you use equals or does not equal, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type.

        Note

        You can't use the resources.ARN field to filter resource types that do not have ARNs.

        For more information about the ARN formats of data event resources, see Actions, resources, and condition keys for Amazon Web Services services in the Service Authorization Reference.

    2. For each field, choose + Condition to add as many conditions as you need, up to a maximum of 500 specified values for all conditions. For example, to exclude data events for two S3 buckets from data events that are logged on your event data store, you can set the field to resources.ARN, set the operator for does not start with, and then paste in an S3 bucket ARN for which you do not want to log events.

      To add the second S3 bucket, choose + Condition, and then repeat the preceding instruction, pasting in the ARN for or browsing for a different bucket.

      For information about how CloudTrail evaluates multiple conditions, see How CloudTrail evaluates multiple conditions for a field.

      Note

      You can have a maximum of 500 values for all selectors on an event data store. This includes arrays of multiple values for a selector such as eventName. If you have single values for all selectors, you can have a maximum of 500 conditions added to a selector.

    3. Choose + Field to add additional fields as required. To avoid errors, do not set conflicting or duplicate values for fields. For example, do not specify an ARN in one selector to be equal to a value, then specify that the ARN not equal the same value in another selector.

  10. To add another resource type on which to log data events, choose Add data event type. Repeat steps 6 through this step to configure advanced event selectors for another resource type.

  11. After you've reviewed and verified your choices, choose Save changes.

In the Amazon Web Services Management Console, if your trail is using advanced event selectors, you can choose from predefined templates that log all data events on a selected resource. After you choose a log selector template, you can customize the template to include only the data events you most want to see. For more information about using advanced event selectors, see Filtering data events by using advanced event selectors in this topic.

  1. On the Dashboard or Trails pages of the CloudTrail console, choose the trail you want to update.

  2. On the details page, in Data events, choose Edit.

  3. If you are not already logging data events, choose the Data events check box.

  4. For Resource type, choose the resource type on which you want to log data events.

  5. Choose a log selector template. You can choose a predefined template, or choose Custom to define your own event collection conditions.

    You can choose from the following predefined templates:

    • Log all events – Choose this template to log all events.

    • Log only read events – Choose this template to log only read events. Read-only events are events that do not change the state of a resource, such as Get* or Describe* events.

    • Log only write events – Choose this template to log only write events. Write events add, change, or delete resources, attributes, or artifacts, such as Put*, Delete*, or Write* events.

    • Log only Amazon Web Services Management Console events – Choose this template to log only events originating from the Amazon Web Services Management Console.

    • Exclude Amazon Web Services service initiated events – Choose this template to exclude Amazon Web Services service events, which have an eventType of AwsServiceEvent, and events initiated with Amazon Web Services service-linked roles (SLRs).

    Note

    Choosing a predefined template for S3 buckets enables data event logging for all buckets currently in your Amazon account and any buckets you create after you finish creating the trail. It also enables logging of data event activity performed by any user or role in your Amazon account, even if that activity is performed on a bucket that belongs to another Amazon account.

    If the trail applies only to one Region, choosing a predefined template that logs all S3 buckets enables data event logging for all buckets in the same Region as your trail and any buckets you create later in that Region. It will not log data events for Amazon S3 buckets in other Regions in your Amazon account.

    If you are creating a trail for all Regions, choosing a predefined template for Lambda functions enables data event logging for all functions currently in your Amazon account, and any Lambda functions you might create in any Region after you finish creating the trail. If you are creating a trail for a single Region (for trails, this only can be done by using the Amazon CLI), this selection enables data event logging for all functions currently in that Region in your Amazon account, and any Lambda functions you might create in that Region after you finish creating the trail. It does not enable data event logging for Lambda functions created in other Regions.

    Logging data events for all functions also enables logging of data event activity performed by any user or role in your Amazon account, even if that activity is performed on a function that belongs to another Amazon account.

  6. (Optional) In Selector name, enter a name to identify your selector. The selector name is a descriptive name for an advanced event selector, such as "Log data events for only two S3 buckets". The selector name is listed as Name in the advanced event selector and is viewable if you expand the JSON view.

  7. If you selected Custom, in Advanced event selectors build an expression based on the values of advanced event selector fields.

    Note

    Selectors don't support the use of wildcards like * . To match multiple values with a single condition, you may use StartsWith, EndsWith, NotStartsWith, or NotEndsWith to explicitly match the beginning or end of the event field.

    1. Choose from the following fields.

      • readOnly - readOnly can be set to equals a value of true or false. Read-only data events are events that do not change the state of a resource, such as Get* or Describe* events. Write events add, change, or delete resources, attributes, or artifacts, such as Put*, Delete*, or Write* events. To log both read and write events, don't add a readOnly selector.

      • eventName - eventName can use any operator. You can use it to include or exclude any data event logged to CloudTrail, such as PutBucket, GetItem, or GetSnapshotBlock.

      • eventSource – The event source to include or exclude. This field can use any operator.

      • eventType – The event type to include or exclude. For example, you can set this field to not equals AwsServiceEvent to exclude Amazon Web Services service events. For a list of event types, see eventType in CloudTrail record contents for management, data, and network activity events.

      • sessionCredentialFromConsole – Include or exclude events originating from an Amazon Web Services Management Console session. This field can be set to equals or not equals with a value of true.

      • userIdentity.arn – Include or exclude events for actions taken by specific IAM identities. For more information, see CloudTrail userIdentity element.

      • resources.ARN - You can use any operator with resources.ARN, but if you use equals or does not equal, the value must exactly match the ARN of a valid resource of the type you've specified in the template as the value of resources.type.

        Note

        You can't use the resources.ARN field to filter resource types that do not have ARNs.

        For more information about the ARN formats of data event resources, see Actions, resources, and condition keys for Amazon Web Services services in the Service Authorization Reference.

    2. For each field, choose + Condition to add as many conditions as you need, up to a maximum of 500 specified values for all conditions. For example, to exclude data events for two S3 buckets from data events that are logged on your event data store, you can set the field to resources.ARN, set the operator for does not start with, and then paste in an S3 bucket ARN for which you do not want to log events.

      To add the second S3 bucket, choose + Condition, and then repeat the preceding instruction, pasting in the ARN for or browsing for a different bucket.

      For information about how CloudTrail evaluates multiple conditions, see How CloudTrail evaluates multiple conditions for a field.

      Note

      You can have a maximum of 500 values for all selectors on an event data store. This includes arrays of multiple values for a selector such as eventName. If you have single values for all selectors, you can have a maximum of 500 conditions added to a selector.

    3. Choose + Field to add additional fields as required. To avoid errors, do not set conflicting or duplicate values for fields. For example, do not specify an ARN in one selector to be equal to a value, then specify that the ARN not equal the same value in another selector.

  8. To add another resource type on which to log data events, choose Add data event type. Repeat steps 4 through this step to configure advanced event selectors for the resource type.

  9. After you've reviewed and verified your choices, choose Save changes.

Use the following procedure to update an existing trail to log data events using basic event selectors.

  1. Sign in to the Amazon Web Services Management Console and open the CloudTrail console at https://console.amazonaws.cn/cloudtrail/.

  2. Open the Trails page of the CloudTrail console and choose the trail name.

    Note

    While you can edit an existing trail to log data events, as a best practice, consider creating a separate trail specifically for logging data events.

  3. For Data events, choose Edit.

  4. For Amazon S3 buckets:

    1. For Data event source, choose S3.

    2. You can choose to log All current and future S3 buckets, or you can specify individual buckets or functions. By default, data events are logged for all current and future S3 buckets.

      Note

      Keeping the default All current and future S3 buckets option enables data event logging for all buckets currently in your Amazon account and any buckets you create after you finish creating the trail. It also enables logging of data event activity performed by any user or role in your Amazon account, even if that activity is performed on a bucket that belongs to another Amazon account.

      If you are creating a trail for a single Region (done by using the Amazon CLI), selecting the Select all S3 buckets in your account option enables data event logging for all buckets in the same Region as your trail and any buckets you create later in that Region. It will not log data events for Amazon S3 buckets in other Regions in your Amazon account.

    3. If you leave the default, All current and future S3 buckets, choose to log Read events, Write events, or both.

    4. To select individual buckets, empty the Read and Write check boxes for All current and future S3 buckets. In Individual bucket selection, browse for a bucket on which to log data events. To find specific buckets, type a bucket prefix for the bucket you want. You can select multiple buckets in this window. Choose Add bucket to log data events for more buckets. Choose to log Read events, such as GetObject, Write events, such as PutObject, or both.

      This setting takes precedence over individual settings you configure for individual buckets. For example, if you specify logging Read events for all S3 buckets, and then choose to add a specific bucket for data event logging, Read is already selected for the bucket you added. You cannot clear the selection. You can only configure the option for Write.

      To remove a bucket from logging, choose X.

  5. To add another resource type on which to log data events, choose Add data event type.

  6. For Lambda functions:

    1. For Data event source, choose Lambda.

    2. In Lambda function, choose All regions to log all Lambda functions, or Input function as ARN to log data events on a specific function.

      To log data events for all Lambda functions in your Amazon account, select Log all current and future functions. This setting takes precedence over individual settings you configure for individual functions. All functions are logged, even if all functions are not displayed.

      Note

      If you are creating a trail for all Regions, this selection enables data event logging for all functions currently in your Amazon account, and any Lambda functions you might create in any Region after you finish creating the trail. If you are creating a trail for a single Region (done by using the Amazon CLI), this selection enables data event logging for all functions currently in that Region in your Amazon account, and any Lambda functions you might create in that Region after you finish creating the trail. It does not enable data event logging for Lambda functions created in other Regions.

      Logging data events for all functions also enables logging of data event activity performed by any user or role in your Amazon account, even if that activity is performed on a function that belongs to another Amazon account.

    3. If you choose Input function as ARN, enter the ARN of a Lambda function.

      Note

      If you have more than 15,000 Lambda functions in your account, you cannot view or select all functions in the CloudTrail console when creating a trail. You can still select the option to log all functions, even if they are not displayed. If you want to log data events for specific functions, you can manually add a function if you know its ARN. You can also finish creating the trail in the console, and then use the Amazon CLI and the put-event-selectors command to configure data event logging for specific Lambda functions. For more information, see Managing trails with the Amazon CLI.

  7. To add another resource type on which to log data events, choose Add data event type.

  8. For DynamoDB tables:

    1. For Data event source, choose DynamoDB.

    2. In DynamoDB table selection, choose Browse to select a table, or paste in the ARN of a DynamoDB table to which you have access. A DynamoDB table ARN uses the following format:

      arn:partition:dynamodb:region:account_ID:table/table_name

      To add another table, choose Add row, and browse for a table or paste in the ARN of a table to which you have access.

  9. Choose Save changes.

Logging data events with the Amazon Command Line Interface

You can configure your trails to log data events using the Amazon CLI.

Logging data events for trails with the Amazon CLI

You can configure your trails to log management and data events using the Amazon CLI.

Note
  • Be aware that if your account is logging more than one copy of management events, you incur charges. There is always a charge for logging data events. For more information, see Amazon CloudTrail Pricing.

  • You can use either advanced event selectors or basic event selectors, but not both. If you apply advanced event selectors to a trail, any existing basic event selectors are overwritten.

  • If your trail uses basic event selectors, you can only log the following resource types:

    • AWS::DynamoDB::Table

    • AWS::Lambda::Function

    • AWS::S3::Object

    To log additional resource types, you'll need to use advanced event selectors. To convert a trail to advanced event selectors, run the get-event-selectors command to confirm the current event selectors, and then configure the advanced event selectors to match the coverage of the previous event selectors, then add selectors for any resource types for which you want to log data events.

  • You can use advanced event selectors to filter based on the value of the supported advanced event selector fieldssupported advanced event selector fields, giving you the ability to log only the data events of interest. For more information about configuring these fields, see AdvancedFieldSelector in the Amazon CloudTrail API Reference and Filtering data events by using advanced event selectors in this guide.

To see whether your trail is logging management and data events, run the get-event-selectors command.

aws cloudtrail get-event-selectors --trail-name TrailName

The command returns the event selectors for the trail.

Log data events for trails by using advanced event selectors

Note

If you apply advanced event selectors to a trail, any existing basic event selectors are overwritten. Before configuring advanced event selectors, run the get-event-selectors command to confirm the current event selectors, and then configure the advanced event selectors to match the coverage of the previous event selectors, then add selectors for any additional data events you want to log.

The following example creates custom advanced event selectors for a trail named TrailName to include read and write management events (by omitting the readOnly selector), PutObject and DeleteObject data events for all Amazon S3 bucket/prefix combinations except for a bucket named amzn-s3-demo-bucket and data events for an Amazon Lambda function named MyLambdaFunction. Because these are custom advanced event selectors, each set of selectors has a descriptive name. Note that a trailing slash is part of the ARN value for S3 buckets.

aws cloudtrail put-event-selectors --trail-name TrailName --advanced-event-selectors '[ { "Name": "Log readOnly and writeOnly management events", "FieldSelectors": [ { "Field": "eventCategory", "Equals": ["Management"] } ] }, { "Name": "Log PutObject and DeleteObject events for all but one bucket", "FieldSelectors": [ { "Field": "eventCategory", "Equals": ["Data"] }, { "Field": "resources.type", "Equals": ["AWS::S3::Object"] }, { "Field": "eventName", "Equals": ["PutObject","DeleteObject"] }, { "Field": "resources.ARN", "NotStartsWith": ["arn:aws:s3:::amzn-s3-demo-bucket/"] } ] }, { "Name": "Log data plane actions on MyLambdaFunction", "FieldSelectors": [ { "Field": "eventCategory", "Equals": ["Data"] }, { "Field": "resources.type", "Equals": ["AWS::Lambda::Function"] }, { "Field": "resources.ARN", "Equals": ["arn:aws:lambda:us-east-2:111122223333:function/MyLambdaFunction"] } ] } ]'

The example returns the advanced event selectors that are configured for the trail.

{ "AdvancedEventSelectors": [ { "Name": "Log readOnly and writeOnly management events", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Management" ] } ] }, { "Name": "Log PutObject and DeleteObject events for all but one bucket", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Data" ] }, { "Field": "resources.type", "Equals": [ "AWS::S3::Object" ] }, { "Field": "resources.ARN", "NotStartsWith": [ "arn:aws:s3:::amzn-s3-demo-bucket/" ] }, ] }, { "Name": "Log data plane actions on MyLambdaFunction", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Data" ] }, { "Field": "resources.type", "Equals": [ "AWS::Lambda::Function" ] }, { "Field": "eventName", "Equals": [ "Invoke" ] }, { "Field": "resources.ARN", "Equals": [ "arn:aws:lambda:us-east-2:111122223333:function/MyLambdaFunction" ] } ] } ], "TrailARN": "arn:aws:cloudtrail:us-east-2:123456789012:trail/TrailName" }

Log all Amazon S3 events for an Amazon S3 bucket by using advanced event selectors

Note

If you apply advanced event selectors to a trail, any existing basic event selectors are overwritten.

The following example shows how to configure your trail to include all data events for all Amazon S3 objects in a specific S3 bucket. The value for S3 events for the resources.type field is AWS::S3::Object. Because the ARN values for S3 objects and S3 buckets are slightly different, you must add the StartsWith operator for resources.ARN to capture all events.

aws cloudtrail put-event-selectors --trail-name TrailName --region region \ --advanced-event-selectors \ '[ { "Name": "S3EventSelector", "FieldSelectors": [ { "Field": "eventCategory", "Equals": ["Data"] }, { "Field": "resources.type", "Equals": ["AWS::S3::Object"] }, { "Field": "resources.ARN", "StartsWith": ["arn:partition:s3:::amzn-s3-demo-bucket/"] } ] } ]'

The command returns the following example output.

{ "TrailARN": "arn:aws:cloudtrail:region:account_ID:trail/TrailName", "AdvancedEventSelectors": [ { "Name": "S3EventSelector", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Data" ] }, { "Field": "resources.type", "Equals": [ "AWS::S3::Object" ] }, { "Field": "resources.ARN", "StartsWith": [ "arn:partition:s3:::amzn-s3-demo-bucket/" ] } ] } ] }

Log Amazon S3 on Amazon Outposts events by using advanced event selectors

Note

If you apply advanced event selectors to a trail, any existing basic event selectors are overwritten.

The following example shows how to configure your trail to include all data events for all Amazon S3 on Outposts objects in your outpost.

aws cloudtrail put-event-selectors --trail-name TrailName --region region \ --advanced-event-selectors \ '[ { "Name": "OutpostsEventSelector", "FieldSelectors": [ { "Field": "eventCategory", "Equals": ["Data"] }, { "Field": "resources.type", "Equals": ["AWS::S3Outposts::Object"] } ] } ]'

The command returns the following example output.

{ "TrailARN": "arn:aws:cloudtrail:region:account_ID:trail/TrailName", "AdvancedEventSelectors": [ { "Name": "OutpostsEventSelector", "FieldSelectors": [ { "Field": "eventCategory", "Equals": [ "Data" ] }, { "Field": "resources.type", "Equals": [ "AWS::S3Outposts::Object" ] } ] } ] }

Log events by using basic event selectors

The following is an example result of the get-event-selectors command showing basic event selectors. By default, when you create a trail by using the Amazon CLI, a trail logs all management events. By default, trails do not log data events.

{ "TrailARN": "arn:aws:cloudtrail:us-east-2:123456789012:trail/TrailName", "EventSelectors": [ { "IncludeManagementEvents": true, "DataResources": [], "ReadWriteType": "All" } ] }

To configure your trail to log management and data events, run the put-event-selectors command.

The following example shows how to use basic event selectors to configure your trail to include all management and data events for the S3 objects in two S3 bucket prefixes. You can specify from 1 to 5 event selectors for a trail. You can specify from 1 to 250 data resources for a trail.

Note

The maximum number of S3 data resources is 250, if you choose to limit data events by using basic event selectors.

aws cloudtrail put-event-selectors --trail-name TrailName --event-selectors '[{ "ReadWriteType": "All", "IncludeManagementEvents":true, "DataResources": [{ "Type": "AWS::S3::Object", "Values": ["arn:aws:s3:::amzn-s3-demo-bucket1/prefix", "arn:aws:s3:::amzn-s3-demo-bucket2;/prefix2"] }] }]'

The command returns the event selectors that are configured for the trail.

{ "TrailARN": "arn:aws:cloudtrail:us-east-2:123456789012:trail/TrailName", "EventSelectors": [ { "IncludeManagementEvents": true, "DataResources": [ { "Values": [ "arn:aws:s3:::amzn-s3-demo-bucket1/prefix", "arn:aws:s3:::amzn-s3-demo-bucket2/prefix2", ], "Type": "AWS::S3::Object" } ], "ReadWriteType": "All" } ] }

Logging data events with the Amazon SDKs

Run the GetEventSelectors operation to see whether your trail is logging data events. You can configure your trails to log data events by running the PutEventSelectors operation. For more information, see the Amazon CloudTrail API Reference.