How CloudTrail works
CloudTrail is active in your AWS account when you create it. When activity occurs in your AWS account, that activity is recorded in a CloudTrail event. You can view the past 90 days of recorded API activity (management events) in an AWS Region in the CloudTrail console by going to Event history.
For an ongoing record of events in your AWS account, create an event data store or a trail. Trails can log events for CloudTrail management, data, and Insights events. Event data stores can log CloudTrail management and data events, CloudTrail Insights events, AWS Config configuration items, AWS Audit Manager evidence, and non-AWS events from integrations.
To get started with CloudTrail, see Getting started with AWS CloudTrail tutorials.
For CloudTrail pricing, see AWS CloudTrail
Pricing
Event history
The Event history provides a viewable, searchable, downloadable,
and immutable record of the past 90 days of recorded management events in an AWS Region. You can easily view management events in the CloudTrail console by going to the Event
history page. You can also view the event history by running the aws cloudtrail lookup-events command,
or the LookupEvents
API operation. You can search events in
Event history by filtering for events on a single
attribute. For more information, see Working with CloudTrail Event history.
The Event history is not connected to any trails or event data stores that exist in your account and is not affected by configuration changes you make to your trails and event data stores.
CloudTrail Lake and event data stores
You can create a CloudTrail Lake event data store to archive, analyze, and respond to
changes in your AWS resources. CloudTrail Lake converts existing
events in row-based JSON format to Apache ORC
You can create an event data store to collect CloudTrail management and data events, CloudTrail Insights events, AWS Config configuration items, AWS Audit Manager evidence, or non-AWS events. You can create event data stores using the console, the AWS CLI, or the CloudTrail API. For more information about creating event data stores using the console, see Create an event data store. For more information about creating event data stores using the AWS CLI, see Managing CloudTrail Lake by using the AWS CLI.
CloudTrail Lake lets you log events from applications outside of AWS, including from any source in your hybrid environments, such as in-house or SaaS applications hosted on-premises or in the cloud, virtual machines, or containers by creating integrations. You can create integrations with more than 12 partners to log events that occur outside AWS to your event data stores. To create an integration, you first configure a channel over which events are delivered. You can use CloudTrail Lake to store, access, analyze, troubleshoot and take action on this data without maintaining multiple log aggregators and reporting tools.
Event data stores can log events from the current AWS Region, or from all AWS Regions in your AWS account. Event data stores that you are using to log Integration events from outside AWS must be for a single Region only; they cannot be multi-Region event data stores.
To change an event data store after you create it, you can run the update-event-data-store
If you have created an organization in AWS Organizations, you can create an organization event data store that logs all events for all AWS accounts in that organization. Organization event data stores can apply to all AWS Regions, or the current Region. Organization event data stores must be created using the management account or delegated administrator account, and when specified as applying to an organization, are automatically applied to all member accounts in the organization. Member accounts cannot see the organization event data store, nor can they modify or delete it. By default, member accounts do not have access to the log files for an organization event data store, nor can they run queries on organization event data stores. Organization event data stores cannot be used to collect events from outside of AWS. For more information, see Organization event data stores.
For more information about how to get started with CloudTrail Lake, see Working with AWS CloudTrail Lake in this guide.
CloudTrail trails
You can also create a CloudTrail trail to archive, analyze, and respond to changes in your AWS resources. Trails can log CloudTrail management events, data events, and Insights events.
A trail is a configuration that enables delivery of events to an Amazon S3 bucket that you specify. You can also deliver and analyze events in a trail with Amazon CloudWatch Logs and Amazon EventBridge. You can create trails with the CloudTrail console, the AWS CLI, or the CloudTrail API.
You can create two types of trails for an AWS account:
- A trail that applies to all Regions
-
When you create a trail that applies to all Regions, CloudTrail records events in each Region and delivers the CloudTrail event log files to an S3 bucket that you specify. If a Region is added after you create a trail that applies to all Regions, that new Region is automatically included, and events in that Region are logged. Creating a multi-Region trail is a recommended best practice since you capture activity in all Regions in your account. All trails you create using the CloudTrail console are multi-Region. You can update a single-Region trail to log all Regions by using the AWS CLI. For more information, see Creating a trail in the console and Converting a trail that applies to one Region to apply to all Regions.
- A trail that applies to one Region
-
When you create a trail that applies to one Region, CloudTrail records the events in that Region only. It then delivers the CloudTrail event log files to an Amazon S3 bucket that you specify. You can only create a single-Region trail by using the AWS CLI. If you create additional single trails, you can have those trails deliver CloudTrail event log files to the same Amazon S3 bucket or to separate buckets. This is the default option when you create a trail using the AWS CLI or the CloudTrail API. For more information, see Creating, updating, and managing trails with the AWS Command Line Interface.
Note
For both types of trails, you can specify an Amazon S3 bucket from any Region.
Beginning on April 12, 2019, trails are viewable only in the AWS Regions where they log events. If you create a trail that logs events in all AWS Regions, it will appear in the console in all AWS Regions. If you create a trail that only logs events in a single AWS Region, you can view and manage it only in that AWS Region.
If you have created an organization in AWS Organizations, you can create an organization trail that logs all events for all AWS accounts in that organization. Organization trails can apply to all AWS Regions, or the current Region. Organization trails must be created using the management account or delegated administrator account, and when specified as applying to an organization, are automatically applied to all member accounts in the organization. Member accounts can see the organization trail , but cannot modify or delete it. By default, member accounts do not have access to the log files for an organization trail in the Amazon S3 bucket.
You can change the configuration of a trail after you create it, including whether it logs events in one Region or all Regions. To change a single-Region trail to an all-Region trail, or vice-versa, you must run the AWS CLI update-trail command. You can also change whether it logs data or CloudTrail Insights events. Changing whether a trail logs events in one Region or in all Regions affects which events are logged. For more information, see Managing trails with the AWS CLI (AWS CLI), and Working with CloudTrail log files.
By default, CloudTrail event log files from trails are encrypted using Amazon S3 server-side encryption (SSE). You can also choose to encrypt your log files with an AWS Key Management Service (AWS KMS) key. You can store your log files in your bucket for as long as you want. You can also define Amazon S3 lifecycle rules to archive or delete log files automatically. If you want notifications about log file delivery and validation, you can set up Amazon SNS notifications.
CloudTrail publishes log files multiple times an hour, about every 5 minutes. These log files contain API calls from services in the account that support CloudTrail. For more information, see CloudTrail supported services and integrations.
Note
CloudTrail typically delivers logs within an average of about 5 minutes of an
API call. This time is not guaranteed. Review the AWS CloudTrail Service Level Agreement
If you misconfigure your trail (for example, the S3 bucket is unreachable), CloudTrail will attempt to redeliver the log files to your S3 bucket for 30 days, and these attempted-to-deliver events will be subject to standard CloudTrail charges. To avoid charges on a misconfigured trail, you need to delete the trail.
CloudTrail captures actions made directly by the user or on behalf of the user by an AWS
service. For example, an AWS CloudFormation CreateStack
call can result in additional
API calls to Amazon EC2, Amazon RDS, Amazon EBS, or other services as required by the AWS CloudFormation template.
This behavior is normal and expected. You can identify if the action was taken by an
AWS service with the invokedby
field in the CloudTrail event.
CloudTrail channels
CloudTrail supports two types of channels:
- Channels for CloudTrail Lake integrations with event sources outside of AWS
-
CloudTrail Lake uses channels to bring non-AWS events into CloudTrail Lake from external partners that work with CloudTrail, or from your own sources. When you create a channel, you choose one or more event data stores to store events that arrive from the channel source. You can change the destination event data stores for a channel as needed, as long as the destination event data stores are set to log activity events. When you create a channel for events from an external partner, you provide a channel ARN to the partner or source application. The resource policy attached to the channel allows the source to transmit events through the channel. For more information, see Create an integration with an event source outside of AWS and
CreateChannel
in the AWS CloudTrail API Reference. - Service-linked channels
-
AWS services can create a service-linked channel to receive CloudTrail events on your behalf. The AWS service creating the service-linked channel configures advanced event selectors for the channel and specifies whether the channel applies to all Regions, or a single Region.
Using the AWS CLI, you can view information about any CloudTrail service-linked channels created by AWS services. For more information, see Service-linked channels.