Provides a CloudTrail Event Data Store.
More information about event data stores can be found in the Event Data Store User Guide.
The most simple event data store configuration requires us to only set the name
attribute. The event data store will automatically capture all management events. To capture management events from all the regions, multi_region_enabled
must be true
.
resource "aws_cloudtrail_event_data_store" "example" {
name = "example-event-data-store"
}
CloudTrail can log Data Events for certain services such as S3 bucket objects and Lambda function invocations. Additional information about data event configuration can be found in the following links:
data "aws_dynamodb_table" "table" {
name = "not-important-dynamodb-table"
}
resource "aws_cloudtrail_event_data_store" "example" {
# ... other configuration ...
advanced_event_selector {
name = "Log all DynamoDB PutEvent actions for a specific DynamoDB table"
field_selector {
field = "eventCategory"
equals = ["Data"]
}
field_selector {
field = "resources.type"
equals = [
"AWS::DynamoDB::Table"
]
}
field_selector {
field = "eventName"
equals = ["PutItem"]
}
field_selector {
field = "resources.ARN"
equals = [
data.aws_dynamodb_table.table.arn
]
}
}
}
This resource supports the following arguments:
name
- (Required) The name of the event data store.advanced_event_selector
- (Optional) The advanced event selectors to use to select the events for the data store. For more information about how to use advanced event selectors, see Log events by using advanced event selectors in the CloudTrail User Guide.multi_region_enabled
- (Optional) Specifies whether the event data store includes events from all regions, or only from the region in which the event data store is created. Default: true
.organization_enabled
- (Optional) Specifies whether an event data store collects events logged for an organization in AWS Organizations. Default: false
.retention_period
- (Optional) The retention period of the event data store, in days. You can set a retention period of up to 2555 days, the equivalent of seven years. Default: 2555
.kms_key_id
- Specifies the AWS KMS key ID to use to encrypt the events delivered by CloudTrail. The value can be an alias name prefixed by alias/, a fully specified ARN to an alias, a fully specified ARN to a key, or a globally unique identifier.tags
- (Optional) A map of tags to assign to the resource. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.termination_protection_enabled
- (Optional) Specifies whether termination protection is enabled for the event data store. If termination protection is enabled, you cannot delete the event data store until termination protection is disabled. Default: true
.advanced_event_selector
supports the following arguments:
name
(Optional) - Specifies the name of the advanced event selector.field_selector
(Required) - Specifies the selector statements in an advanced event selector. Fields documented below.field_selector
supports the following arguments:
field
(Required) - Specifies a field in an event record on which to filter events to be logged. You can specify only the following values: readOnly
, eventSource
, eventName
, eventCategory
, resources.type
, resources.ARN
.equals
(Optional) - A list of values that includes events that match the exact value of the event record field specified as the value of field
. This is the only valid operator that you can use with the readOnly
, eventCategory
, and resources.type
fields.not_equals
(Optional) - A list of values that excludes events that match the exact value of the event record field specified as the value of field
.starts_with
(Optional) - A list of values that includes events that match the first few characters of the event record field specified as the value of field
.not_starts_with
(Optional) - A list of values that excludes events that match the first few characters of the event record field specified as the value of field
.ends_with
(Optional) - A list of values that includes events that match the last few characters of the event record field specified as the value of field
.not_ends_with
(Optional) - A list of values that excludes events that match the last few characters of the event record field specified as the value of field
.This resource exports the following attributes in addition to the arguments above:
arn
- ARN of the event data store.id
- Name of the event data store.tags_all
- Map of tags assigned to the resource, including those inherited from the provider default_tags
configuration block.In Terraform v1.5.0 and later, use an import
block to import event data stores using their arn
. For example:
import {
to = aws_cloudtrail_event_data_store.example
id = "arn:aws:cloudtrail:us-east-1:123456789123:eventdatastore/22333815-4414-412c-b155-dd254033gfhf"
}
Using terraform import
, import event data stores using their arn
. For example:
% terraform import aws_cloudtrail_event_data_store.example arn:aws:cloudtrail:us-east-1:123456789123:eventdatastore/22333815-4414-412c-b155-dd254033gfhf