-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
68 lines (64 loc) · 1.93 KB
/
s3.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
module "s3_account_block_public_access" {
source = "terraform-aws-modules/s3-bucket/aws//modules/account-public-access"
account_id = data.aws_caller_identity.current.account_id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
module "s3_bucket_config" {
source = "terraform-aws-modules/s3-bucket/aws"
attach_policy = true
bucket_prefix = "config-recorder-"
force_destroy = true
policy = <<-EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AWSConfigBucketPermissionsCheck",
"Effect": "Allow",
"Principal": {
"Service": "config.amazonaws.com"
},
"Action": "s3:GetBucketAcl",
"Resource": "${module.s3_bucket_config.s3_bucket_arn}",
"Condition": {
"StringEquals": {
"AWS:SourceAccount": "${data.aws_caller_identity.current.account_id}"
}
}
},
{
"Sid": "AWSConfigBucketExistenceCheck",
"Effect": "Allow",
"Principal": {
"Service": "config.amazonaws.com"
},
"Action": "s3:ListBucket",
"Resource": "${module.s3_bucket_config.s3_bucket_arn}",
"Condition": {
"StringEquals": {
"AWS:SourceAccount": "${data.aws_caller_identity.current.account_id}"
}
}
},
{
"Sid": "AWSConfigBucketDelivery",
"Effect": "Allow",
"Principal": {
"Service": "config.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "${module.s3_bucket_config.s3_bucket_arn}/AWSLogs/${data.aws_caller_identity.current.account_id}/Config/*",
"Condition": {
"StringEquals": {
"s3:x-amz-acl": "bucket-owner-full-control",
"AWS:SourceAccount": "${data.aws_caller_identity.current.account_id}"
}
}
}
]
}
EOF
}