Create an event data store for CloudTrail events with the console - 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).

Create an event data store for CloudTrail events with the console

Event data stores for CloudTrail events can log CloudTrail management and data events. You can keep the event data in an event data store for up to 3,653 days (about 10 years) if you choose the One-year extendable retention pricing option, or up to 2,557 days (about 7 years) if you choose the Seven-year retention pricing option..

CloudTrail Lake event data stores incur charges. When you create an event data store, you choose the pricing option you want to use for the event data store. The pricing option determines the cost for ingesting and storing events, and the default and maximum retention period for the event data store. For information about CloudTrail pricing and managing Lake costs, see Amazon CloudTrail Pricing and Managing CloudTrail Lake costs.

To create an event data store for CloudTrail management or data events

Use this procedure to create an event data store that logs CloudTrail management events, data events, or both management and data events.

  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. Choose Create event data store.

  4. On the Configure event data store page, in General details, enter a name for the event data store. A name is required.

  5. Choose the Pricing option that you want to use for your event data store. The pricing option determines the cost for ingesting and storing events, and the default and maximum retention periods for your event data store. For more information, see Amazon CloudTrail Pricing and Managing CloudTrail Lake costs.

    The following are the available options:

    • One-year extendable retention pricing - Generally recommended if you expect to ingest less than 25 TB of event data per month and want a flexible retention period of up to 10 years. For the first 366 days (the default retention period), storage is included at no additional charge with ingestion pricing. After 366 days, extended retention is available at pay-as-you-go pricing. This is the default option.

      • Default retention period: 366 days

      • Maximum retention period: 3,653 days

    • Seven-year retention pricing - Recommended if you expect to ingest more than 25 TB of event data per month and need a retention period of up to 7 years. Retention is included with ingestion pricing at no additional charge.

      • Default retention period: 2,557 days

      • Maximum retention period: 2,557 days

  6. Specify a retention period for the event data store. Retention periods can be between 7 days and 3,653 days (about 10 years) for the One-year extendable retention pricing option, or between 7 days and 2,557 days (about seven years) for the Seven-year retention pricing option.

    CloudTrail Lake determines whether to retain an event by checking if the eventTime of the event is within the specified retention period. For example, if you specify a retention period of 90 days, CloudTrail will remove events when their eventTime is older than 90 days.

    Note

    If you are copying trail events to this event data store, CloudTrail will not copy an event if its eventTime is older than the specified retention period. To determine the appropriate retention period, take the sum of the oldest event you want to copy in days and the number of days you want to retain the events in the event data store (retention period = oldest-event-in-days + number-days-to-retain). For example, if the oldest event you're copying is 45 days old and you want to keep the events in the event data store for a further 45 days, you would set the retention period to 90 days.

  7. (Optional) To enable encryption using Amazon Key Management Service, choose Use my own Amazon KMS key. Choose New to have an Amazon KMS key created for you, or choose Existing to use an existing KMS key. In Enter KMS alias, specify an alias, in the format alias/MyAliasName. Using your own KMS key requires that you edit your KMS key policy to allow CloudTrail logs to be encrypted and decrypted. For more information, see Configure Amazon KMS key policies for CloudTrail. CloudTrail also supports Amazon KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Amazon Key Management Service Developer Guide.

    Using your own KMS key incurs Amazon KMS costs for encryption and decryption. After you associate an event data store with a KMS key, the KMS key cannot be removed or changed.

    Note

    To enable Amazon Key Management Service encryption for an organization event data store, you must use an existing KMS key for the management account.

  8. (Optional) If you want to query against your event data using Amazon Athena, choose Enable in Lake query federation. Federation lets you view the metadata associated with the event data store in the Amazon Glue Data Catalog and run SQL queries against the event data in Athena. The table metadata stored in the Amazon Glue Data Catalog lets the Athena query engine know how to find, read, and process the data that you want to query. For more information, see Federate an event data store.

    To enable Lake query federation, choose Enable and then do the following:

    1. Choose whether you want to create a new role or use an existing IAM role. Amazon Lake Formation uses this role to manage permissions for the federated event data store. When you create a new role using the CloudTrail console, CloudTrail automatically creates a role with the required permissions. If you choose an existing role, be sure the policy for the role provides the required minimum permissions.

    2. If you are creating a new role, enter a name to identify the role.

    3. If you are using an existing role, choose the role you want to use. The role must exist in your account.

  9. (Optional) In the Tags section, you can add up to 50 tag key pairs to help you identify, sort, and control access to your event data store. For more information about how to use IAM policies to authorize access to an event data store based on tags, see Examples: Denying access to create or delete event data stores based on tags. For more information about how you can use tags in Amazon, see Tagging Amazon resources in the Tagging Amazon Resources User Guide.

  10. Choose Next to configure the event data store.

  11. On the Choose events page, choose Amazon events, and then choose CloudTrail events.

  12. For CloudTrail events, choose at least one event type. By default, Management events is selected. You can add both management and data events to your event data store. For more information about management events, see Logging management events. For more information about data events, see Logging data events.

  13. (Optional) Choose Copy trail events if you want to copy events from an existing trail to run queries on past events. To copy trail events to an organization event data store, you must use the management account for the organization. The delegated administrator account cannot copy trail events to an organization event data store. For more information about considerations for copying trail events, see Considerations for copying trail events.

  14. To have your event data store collect events from all accounts in an Amazon Organizations organization, select Enable for all accounts in my organization. You must be signed in to the management account or delegated administrator account for the organization to create an event data store that collects events for an organization.

    Note

    To copy trail events or enable Insights events, you must be signed in to the management account for your organization.

  15. Expand Additional settings to choose whether you want your event data store to collect events for all Amazon Web Services Regions, or only the current Amazon Web Services Region, and choose whether the event data store ingests events. By default, your event data store collects events from all Regions in your account and starts ingesting events when it's created.

    1. Select Include only the current region in my event data store to include only events that are logged in the current Region. If you do not choose this option, your event data store includes events from all Regions.

    2. Deselect Ingest events if you do not want the event data store to start ingesting events. For example, you may want to deselect Ingest events, if you are copying trail events and do not want the event data store to include any future events. By default, the event data store starts ingesting events when it's created.

  16. If your event data store includes management events, you can choose from the following options. For more information about management events, see Logging management events.

    1. Choose whether you want to include Read events, Write events, or both. At least one is required.

    2. Choose whether to exclude Amazon Key Management Service or Amazon RDS Data API events from your event data store.

    3. Choose whether to enable Insights. To enable Insights, you need to set up a destination event data store to collect Insights events based upon the management event activity in this event data store.

      If you choose to enable Insights, do the following.

      1. In Enable Insights, choose the destination event store that will log Insights events. The destination event data store will collect Insights events based upon the management event activity in this event data store. For information about how to create the destination event data store, see To create a destination event data store that logs Insights events.

      2. Choose the Insights types. You can choose API call rate, API error rate, or both. You must be logging Write management events to log Insights events for API call rate. You must be logging Read or Write management events to log Insights events for API error rate.

  17. To include data events in your event data store, do the following.

    1. Choose a data event type. This is the Amazon Web Service and resource on which data events are logged. To log data events for Amazon Glue tables created by Lake Formation, choose Lake Formation for the data type.

    2. In Log selector template, choose a template. You can choose to log all data events, readOnly events, writeOnly events, or Custom to build a custom log selector.

    3. (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.

    4. In Advanced event selectors, build expressions by choosing values for Field, Operator, and Value. Advanced event selectors for an event data store work the same as advanced event selectors that you apply to a trail. For more information about how to build advanced event selectors, see Logging data events with advanced event selectors.

      The following example uses a Custom log selector template to choose only event names from S3 objects that start with Put, such as PutObject. Because the advanced event selector does not include or exclude any other event types or resource ARNs, all S3 data events, both read and write, that have event names starting with Put, are stored in the event data store.

      Lake data events, advanced event selectors
      Important

      To exclude or include data events with advanced event selectors by using an S3 bucket ARN, always use the Starts with operator.

    5. Optionally, expand JSON view to see your advanced event selectors as a JSON block.

  18. To copy existing trail events to your event data store, do the following.

    1. Choose the trail that you want to copy. By default, CloudTrail only copies CloudTrail events contained in the S3 bucket's CloudTrail prefix and the prefixes inside the CloudTrail prefix, and does not check prefixes for other Amazon services. If you want to copy CloudTrail events contained in another prefix, choose Enter S3 URI, and then choose Browse S3 to browse to the prefix. If the source S3 bucket for the trail uses a KMS key for data encryption, ensure that the KMS key policy allows CloudTrail to decrypt the data. If your source S3 bucket uses multiple KMS keys, you must update each key's policy to allow CloudTrail to decrypt the data in the bucket. For more information about updating the KMS key policy, see KMS key policy for decrypting data in the source S3 bucket.

    2. Choose the time range for copying the events. CloudTrail checks the prefix and log file name to verify the name contains a date between the chosen start and end date before attempting to copy trail events. You can choose a Relative range or an Absolute range. To avoid duplicating events between the source trail and destination event data store, choose a time range that is earlier than the creation of the event data store.

      Note

      CloudTrail only copies trail events that have an eventTime within the event data store’s retention period. For example, if an event data store’s retention period is 90 days, then CloudTrail will not copy any trail events with an eventTime older than 90 days.

      • If you choose Relative range, you can choose to copy events logged in the last 6 months, 1 year, 2 years, 7 years, or a custom range. CloudTrail copies the events logged within the chosen time period.

      • If you choose Absolute range, you can choose a specific start and end date. CloudTrail copies the events that occurred between the chosen start and end dates.

    3. For Permissions, choose from the following IAM role options. If you choose an existing IAM role, verify that the IAM role policy provides the necessary permissions. For more information about updating the IAM role permissions, see IAM permissions for copying trail events.

      • Choose Create a new role (recommended) to create a new IAM role. For Enter IAM role name, enter a name for the role. CloudTrail automatically creates the necessary permissions for this new role.

      • Choose Use a custom IAM role ARN to use a custom IAM role that is not listed. For Enter IAM role ARN, enter the IAM ARN.

      • Choose an existing IAM role from the drop-down list.

  19. Choose Next to review your choices.

  20. On the Review and create page, review your choices. Choose Edit to make changes to a section. When you're ready to create the event data store, choose Create event data store.

  21. The new event data store is visible in the Event data stores table on the Event data stores page.

    From this point forward, the event data store captures events that match its advanced event selectors (if you kept the Ingest events option selected). Events that occurred before you created the event data store are not in the event data store, unless you opted to copy existing trail events.

You can now run queries on your new event data store. The Sample queries tab provides example queries to get you started. For more information about creating and editing queries, see Create or edit a query.

You can also view the CloudTrail Lake dashboard to visualize the events in your event data store. For more information about Lake dashboards, see View CloudTrail Lake dashboards.

Example: Create an event data store for management events

This walkthrough shows you how to create an event data store that logs all management events in all Amazon Regions, and does not log any data events. Examples of management events include security events such as IAM CreateUser and AttachRolePolicy events, resource events such as RunInstances and CreateBucket, and many more.

To create an event data store for management events
  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. Choose Create event data store.

  4. On the Configure event data store page, in General details, give your event data store a name, such as my-management-events-eds. As a best practice, use a name that quickly identifies the purpose of the event data store. For information about CloudTrail naming requirements, see Naming requirements.

  5. Choose the Pricing option that you want to use for your event data store. The pricing option determines the cost for ingesting and storing events, and the default and maximum retention periods for your event data store. For more information, see Amazon CloudTrail Pricing and Managing CloudTrail Lake costs.

    The following are the available options:

    • One-year extendable retention pricing - Generally recommended if you expect to ingest less than 25 TB of event data per month and want a flexible retention period of up to 10 years. For the first 366 days (the default retention period), storage is included at no additional charge with ingestion pricing. After 366 days, extended retention is available at pay-as-you-go pricing. This is the default option.

      • Default retention period: 366 days

      • Maximum retention period: 3,653 days

    • Seven-year retention pricing - Recommended if you expect to ingest more than 25 TB of event data per month and need a retention period of up to 7 years. Retention is included with ingestion pricing at no additional charge.

      • Default retention period: 2,557 days

      • Maximum retention period: 2,557 days

  6. Specify a retention period for the event data store. Retention periods can be between 7 days and 3,653 days (about 10 years) for the One-year extendable retention pricing option, or between 7 days and 2,557 days (about seven years) for the Seven-year retention pricing option.

    CloudTrail Lake determines whether to retain an event by checking if the eventTime of the event is within the specified retention period. For example, if you specify a retention period of 90 days, CloudTrail will remove events when their eventTime is older than 90 days.

  7. (Optional) In Encryption. choose whether you want to encrypt the event data store using your own KMS key. By default, all events in an event data store are encrypted by CloudTrail using a KMS key that Amazon owns and manages for you.

    To enable encryption using your own KMS key, choose Use my own Amazon KMS key. Choose New to have an Amazon KMS key created for you, or choose Existing to use an existing KMS key. In Enter KMS alias, specify an alias, in the format alias/MyAliasName. Using your own KMS key requires that you edit your KMS key policy to allow CloudTrail logs to be encrypted and decrypted. For more information, see Configure Amazon KMS key policies for CloudTrail. CloudTrail also supports Amazon KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Amazon Key Management Service Developer Guide.

    Using your own KMS key incurs Amazon KMS costs for encryption and decryption. After you associate an event data store with a KMS key, the KMS key cannot be removed or changed.

    Note

    To enable Amazon Key Management Service encryption for an organization event data store, you must use an existing KMS key for the management account.

  8. (Optional) If you want to query against your event data using Amazon Athena, choose Enable in Lake query federation. Federation lets you view the metadata associated with the event data store in the Amazon Glue Data Catalog and run SQL queries against the event data in Athena. The table metadata stored in the Amazon Glue Data Catalog lets the Athena query engine know how to find, read, and process the data that you want to query. For more information, see Federate an event data store.

    To enable Lake query federation, choose Enable and then do the following:

    1. Choose whether you want to create a new role or use an existing IAM role. Amazon Lake Formation uses this role to manage permissions for the federated event data store. When you create a new role using the CloudTrail console, CloudTrail automatically creates a role with the required permissions. If you choose an existing role, be sure the policy for the role provides the required minimum permissions.

    2. If you are creating a new role, enter a name to identify the role.

    3. If you are using an existing role, choose the role you want to use. The role must exist in your account.

  9. (Optional) In Tags, add one or more custom tags (key-value pairs) to your event data store. Tags can help you identify your CloudTrail event data stores. For example, you could attach a tag with the name stage and the value prod. You can use tags to limit access to your event data store. You can also use tags to track the query and ingestion costs for your event data store.

    For information about how to use tags to track costs, see Creating user-defined cost allocation tags for CloudTrail Lake event data stores. For information about how to use IAM policies to authorize access to an event data store based on tags, see Examples: Denying access to create or delete event data stores based on tags. For information about how you can use tags in Amazon, see Tagging your Amazon resources in the Tagging Amazon Resources User Guide.

  10. Choose Next to configure the event data store.

  11. On the Choose events page, leave the default selections for Event type.

  12. For CloudTrail events, leave the default selections. By default, CloudTrail event data stores collect management events and don't collect data events. For more information about management events, see Logging management events. For more information about data events, see Logging data events.

  13. Leave the default setting for Copy trail events. You'd use this option to copy existing trail events to your event data store. For more information, see Copy trail events to an event data store.

  14. Choose Enable for all accounts in my organization if this is an organization event data store. This option won't be available to change unless you have accounts configured in Amazon Organizations.

  15. For Additional settings leave the default selections. By default, an event data store collects events for all Amazon Web Services Regions and starts ingesting events when it's created.

  16. For Management events, choose to collect both Read and Write events. Leave the check boxes for Exclude Amazon KMS events and Exclude Amazon RDS Data API events empty, to collect all management events. Leave the check box for Enable Insights events empty.

  17. Choose Next to review your choices.

  18. On the Review and create page, review your choices. Choose Edit to make changes to a section. When you're ready to create the event data store, choose Create event data store.

  19. The new event data store is visible in the Event data stores table on the Event data stores page.

    From this point forward, the event data store captures events that match its advanced event selectors. Events that occurred before you created the event data store are not in the event data store, unless you opted to copy existing trail events.

Example: Create an event data store for S3 data events

This walkthrough shows you how to create an event data store for Amazon S3 data events. In this scenario, instead of logging all Amazon S3 data events, we'll choose a custom log selector template to log events only when an object is deleted from a specific S3 bucket.

To create an event data store for S3 data events
  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. Choose Create event data store.

  4. On the Configure event data store page, in General details, give your event data store a name, such as s3-data-events-eds. As a best practice, use a name that quickly identifies the purpose of the event data store. For information about CloudTrail naming requirements, see Naming requirements.

  5. Choose the Pricing option that you want to use for your event data store. The pricing option determines the cost for ingesting and storing events, and the default and maximum retention periods for your event data store. For more information, see Amazon CloudTrail Pricing and Managing CloudTrail Lake costs.

    The following are the available options:

    • One-year extendable retention pricing - Generally recommended if you expect to ingest less than 25 TB of event data per month and want a flexible retention period of up to 10 years. For the first 366 days (the default retention period), storage is included at no additional charge with ingestion pricing. After 366 days, extended retention is available at pay-as-you-go pricing. This is the default option.

      • Default retention period: 366 days

      • Maximum retention period: 3,653 days

    • Seven-year retention pricing - Recommended if you expect to ingest more than 25 TB of event data per month and need a retention period of up to 7 years. Retention is included with ingestion pricing at no additional charge.

      • Default retention period: 2,557 days

      • Maximum retention period: 2,557 days

  6. Specify a retention period for the event data store. Retention periods can be between 7 days and 3,653 days (about 10 years) for the One-year extendable retention pricing option, or between 7 days and 2,557 days (about seven years) for the Seven-year retention pricing option.

    CloudTrail Lake determines whether to retain an event by checking if the eventTime of the event is within the specified retention period. For example, if you specify a retention period of 90 days, CloudTrail will remove events when their eventTime is older than 90 days.

  7. (Optional) In Encryption. choose whether you want to encrypt the event data store using your own KMS key. By default, all events in an event data store are encrypted by CloudTrail using a KMS key that Amazon owns and manages for you.

    To enable encryption using your own KMS key, choose Use my own Amazon KMS key. Choose New to have an Amazon KMS key created for you, or choose Existing to use an existing KMS key. In Enter KMS alias, specify an alias, in the format alias/MyAliasName. Using your own KMS key requires that you edit your KMS key policy to allow CloudTrail logs to be encrypted and decrypted. For more information, see Configure Amazon KMS key policies for CloudTrail. CloudTrail also supports Amazon KMS multi-Region keys. For more information about multi-Region keys, see Using multi-Region keys in the Amazon Key Management Service Developer Guide.

    Using your own KMS key incurs Amazon KMS costs for encryption and decryption. After you associate an event data store with a KMS key, the KMS key cannot be removed or changed.

    Note

    To enable Amazon Key Management Service encryption for an organization event data store, you must use an existing KMS key for the management account.

  8. (Optional) If you want to query against your event data using Amazon Athena, choose Enable in Lake query federation. Federation lets you view the metadata associated with the event data store in the Amazon Glue Data Catalog and run SQL queries against the event data in Athena. The table metadata stored in the Amazon Glue Data Catalog lets the Athena query engine know how to find, read, and process the data that you want to query. For more information, see Federate an event data store.

    To enable Lake query federation, choose Enable and then do the following:

    1. Choose whether you want to create a new role or use an existing IAM role. Amazon Lake Formation uses this role to manage permissions for the federated event data store. When you create a new role using the CloudTrail console, CloudTrail automatically creates a role with the required permissions. If you choose an existing role, be sure the policy for the role provides the required minimum permissions.

    2. If you are creating a new role, enter a name to identify the role.

    3. If you are using an existing role, choose the role you want to use. The role must exist in your account.

  9. (Optional) In Tags, add one or more custom tags (key-value pairs) to your event data store. Tags can help you identify your CloudTrail event data stores. For example, you could attach a tag with the name stage and the value prod. You can use tags to limit access to your event data store. You can also use tags to track the query and ingestion costs for your event data store.

    For information about how to use tags to track costs, see Creating user-defined cost allocation tags for CloudTrail Lake event data stores. For information about how to use IAM policies to authorize access to an event data store based on tags, see Examples: Denying access to create or delete event data stores based on tags. For information about how you can use tags in Amazon, see Tagging your Amazon resources in the Tagging Amazon Resources User Guide.

  10. Choose Next to configure the event data store.

  11. On the Choose events page, leave the default selections for Event type.

  12. For CloudTrail events, choose Data events and deselect Management events. For more information about data events, see Logging data events.

  13. Leave the default setting for Copy trail events. You'd use this option to copy existing trail events to your event data store. For more information, see Copy trail events to an event data store.

  14. Choose Enable for all accounts in my organization if this is an organization event data store. This option won't be available to change unless you have accounts configured in Amazon Organizations.

  15. For Additional settings leave the default selections. By default, an event data store collects events for all Amazon Web Services Regions and starts ingesting events when it's created.

  16. For Data events, make the following selections:

    1. In Data event type, choose S3. The data event type identifies the Amazon Web Service and resource on which data events are logged.

    2. In Log selector template, choose Custom. Choosing Custom lets you define a custom event selector to filter on the eventName, resources.ARN, and readOnly fields. For information about these fields, see AdvancedFieldSelector in the Amazon CloudTrail API Reference.

    3. (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 DeleteObject API calls for a specific S3 bucket". The selector name is listed as Name in the advanced event selector and is viewable if you expand the JSON view.

    4. In Advanced event selectors, we'll build the custom event selector to filter on the eventName and resources.ARN fields. Advanced event selectors for an event data store work the same as advanced event selectors that you apply to a trail. For more information about how to build advanced event selectors, see Logging data events with advanced event selectors.

      1. For Field choose eventName. For Operator, choose equals. For Value, enter DeleteObject. Choose + Field to filter on another field.

      2. For Field, choose resources.ARN. For Operator, choose StartsWith. For Value, enter the ARN for your bucket (for example, arn:aws:s3:::bucket-name). For information about how to get the ARN, see Amazon S3 resources in the Amazon Simple Storage Service User Guide.

  17. Choose Next to review your choices.

  18. On the Review and create page, review your choices. Choose Edit to make changes to a section. When you're ready to create the event data store, choose Create event data store.

  19. The new event data store is visible in the Event data stores table on the Event data stores page.

    From this point forward, the event data store captures events that match its advanced event selectors. Events that occurred before you created the event data store are not in the event data store, unless you opted to copy existing trail events.