-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
50 lines (43 loc) · 1.24 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
// Create S3 bucket for Runtime Configuration
resource "aws_s3_bucket" "config" {
bucket = "${local.name_prefix}-runtime"
acl = "private"
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AE256"
}
}
}
tags = local.tags
}
data "aws_iam_policy_document" "config" {
statement {
sid = "AWSConfigReadWrite"
actions = [
"s3:putObject",
"s3:GetObject"
]
resources = [
"arn:aws:s3:::${aws_s3_bucket.config.bucket}/*"
]
principal {
type = "AWS"
identifiers = [data.aws_elb_service_account.main.arn]
}
}
statement {
sid = "AWSConfigCheck"
actions = [
"s3:GetBucketAcl",
]
resources = [
"arn:aws:s3:::${aws_s3_bucket.config.bucket}",
]
}
}
// Attach policy above to logs bucket
resource "aws_s3_bucket_policy" "config" {
bucket = aws_s3_bucket.config.bucket
policy = data.aws_iam_policy_document.config.json
}