forked from 100daysofdevops/100daysofdevops
-
Notifications
You must be signed in to change notification settings - Fork 27
/
cloudtrail.tf
46 lines (43 loc) · 1.03 KB
/
cloudtrail.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
provider "aws" {
region = "us-west-2"
}
resource "aws_cloudtrail" "my-demo-cloudtrail" {
name = "my-demo-cloudtrail-terraform"
s3_bucket_name = "${aws_s3_bucket.s3_bucket_name.id}"
include_global_service_events = true
is_multi_region_trail = true
enable_log_file_validation = true
}
resource "aws_s3_bucket" "s3_bucket_name" {
bucket = "s3-cloudtrail-bucket-with-terraform-code"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSCloudTrailAclCheck",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "arn:aws:s3:::s3-cloudtrail-bucket-with-terraform-code"
},
{
"Sid": "AWSCloudTrailWrite",
"Effect": "Allow",
"Principal": {
"Service": "cloudtrail.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::s3-cloudtrail-bucket-with-terraform-code/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control"
}
}
}
]
}
POLICY
}