-
Notifications
You must be signed in to change notification settings - Fork 2
/
module_cloudtrail_bucket.tf
50 lines (43 loc) · 1.48 KB
/
module_cloudtrail_bucket.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
47
48
49
50
module "cloudtrail_bucket" {
source = "git::ssh://[email protected]/osodevops/aws-terraform-module-s3.git"
s3_bucket_name = "cloudtail-${data.aws_caller_identity.current.account_id}"
s3_bucket_policy = data.aws_iam_policy_document.s3_bucket_policy.json
s3_bucket_force_destroy = true
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
s3_sse_algorithm = "aws:kms"
common_tags = var.common_tags
}
data "aws_iam_policy_document" "s3_bucket_policy" {
statement {
sid = "AWSCloudTrailAclCheck"
effect = "Allow"
principals {
type = "Service"
identifiers = [
"cloudtrail.amazonaws.com",
]
}
actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3::cloudtail-${data.aws_caller_identity.current.account_id}"]
}
statement {
sid = "AWSCloudTrailWrite"
effect = "Allow"
principals {
type = "Service"
identifiers = [
"cloudtrail.amazonaws.com",
]
}
actions = ["s3:PutObject"]
resources = ["arn:aws:s3::cloudtail-${data.aws_caller_identity.current.account_id}/AWSLogs/${data.aws_caller_identity.current.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
values = ["bucket-owner-full-control"]
}
}
}