github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/website/source/docs/providers/aws/r/cloudtrail.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: cloudtrail" 4 sidebar_current: "docs-aws-resource-cloudtrail" 5 description: |- 6 Provides a CloudTrail resource. 7 --- 8 9 # aws\_cloudtrail 10 11 Provides a CloudTrail resource. 12 13 ## Example Usage 14 ``` 15 resource "aws_cloudtrail" "foobar" { 16 name = "tf-trail-foobar" 17 s3_bucket_name = "${aws_s3_bucket.foo.id}" 18 s3_key_prefix = "prefix" 19 include_global_service_events = false 20 } 21 22 resource "aws_s3_bucket" "foo" { 23 bucket = "tf-test-trail" 24 force_destroy = true 25 26 policy = <<POLICY 27 { 28 "Version": "2012-10-17", 29 "Statement": [ 30 { 31 "Sid": "AWSCloudTrailAclCheck", 32 "Effect": "Allow", 33 "Principal": { 34 "Service": "cloudtrail.amazonaws.com" 35 }, 36 "Action": "s3:GetBucketAcl", 37 "Resource": "arn:aws:s3:::tf-test-trail" 38 }, 39 { 40 "Sid": "AWSCloudTrailWrite", 41 "Effect": "Allow", 42 "Principal": { 43 "Service": "cloudtrail.amazonaws.com" 44 }, 45 "Action": "s3:PutObject", 46 "Resource": "arn:aws:s3:::tf-test-trail/*", 47 "Condition": { 48 "StringEquals": { 49 "s3:x-amz-acl": "bucket-owner-full-control" 50 } 51 } 52 } 53 ] 54 } 55 POLICY 56 } 57 ``` 58 59 ## Argument Reference 60 61 The following arguments are supported: 62 63 * `name` - (Required) Specifies the name of the trail. 64 * `s3_bucket_name` - (Required) Specifies the name of the S3 bucket designated for publishing log files. 65 * `s3_key_prefix` - (Optional) Specifies the S3 key prefix that precedes 66 the name of the bucket you have designated for log file delivery. 67 * `cloud_watch_logs_role_arn` - (Optional) Specifies the role for the CloudWatch Logs 68 endpoint to assume to write to a user’s log group. 69 * `cloud_watch_logs_group_arn` - (Optional) Specifies a log group name using an Amazon Resource Name (ARN), 70 that represents the log group to which CloudTrail logs will be delivered. 71 * `enable_logging` - (Optional) Enables logging for the trail. Defaults to `true`. 72 Setting this to `false` will pause logging. 73 * `include_global_service_events` - (Optional) Specifies whether the trail is publishing events 74 from global services such as IAM to the log files. Defaults to `true`. 75 * `is_multi_region_trail` - (Optional) Specifies whether the trail is created in the current 76 region or in all regions. Defaults to `false`. 77 * `sns_topic_name` - (Optional) Specifies the name of the Amazon SNS topic 78 defined for notification of log file delivery. 79 * `enable_log_file_validation` - (Optional) Specifies whether log file integrity validation is enabled. 80 Defaults to `false`. 81 * `kms_key_id` - (Optional) Specifies the KMS key ARN to use to encrypt the logs delivered by CloudTrail. 82 * `tags` - (Optional) A mapping of tags to assign to the trail 83 84 ## Attribute Reference 85 86 The following attributes are exported: 87 88 * `id` - The name of the trail. 89 * `home_region` - The region in which the trail was created. 90 * `arn` - The Amazon Resource Name of the trail. 91 92 93 ## Import 94 95 Cloudtrails can be imported using the `name`, e.g. 96 97 ``` 98 $ terraform import aws_cloudtrail.sample my-sample-trail 99 ```