The following arguments are required:
The following arguments are optional:
data "aws_caller_identity" "current" {}
resource "aws_cloudtrail" "foobar" {
name = "tf-trail-foobar"
s3_bucket_name = aws_s3_bucket.foo.id
s3_key_prefix = "prefix"
include_global_service_events = false
}
resource "aws_s3_bucket" "foo" {
bucket = "tf-test-trail"
force_destroy = true
}
data "aws_iam_policy_document" "foo" {
statement {
sid = "AWSCloudTrailAclCheck"
effect = "Allow"
principals {
type = "Service"
identifiers = ["cloudtrail.amazonaws.com"]
}
actions = ["s3:GetBucketAcl"]
resources = [aws_s3_bucket.foo.arn]
}
statement {
sid = "AWSCloudTrailWrite"
effect = "Allow"
principals {
type = "Service"
identifiers = ["cloudtrail.amazonaws.com"]
}
actions = ["s3:PutObject"]
resources = ["${aws_s3_bucket.foo.arn}/prefix/AWSLogs/${data.aws_caller_identity.current.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
}
}
resource "aws_s3_bucket_policy" "foo" {
bucket = aws_s3_bucket.foo.id
policy = data.aws_iam_policy_document.foo.json
}
create-trail
--name <value>
--s3-bucket-name <value>
[--s3-key-prefix <value>]
[--sns-topic-name <value>]
[--include-global-service-events | --no-include-global-service-events]
[--is-multi-region-trail | --no-is-multi-region-trail]
[--enable-log-file-validation | --no-enable-log-file-validation]
[--cloud-watch-logs-log-group-arn <value>]
[--cloud-watch-logs-role-arn <value>]
[--kms-key-id <value>]
[--is-organization-trail | --no-is-organization-trail]
[--tags-list <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
aws cloudtrail create-trail --name Trail1 --s3-bucket-name my-bucket --is-multi-region-trail
$ per data event recorded in <Region>
USD per Events for DataEventsRecorded in <Region>
Categorized by Availability, Security & Compliance and Cost