forked from zoitech/terraform-aws-concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
48 lines (39 loc) · 1.17 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
data "aws_iam_policy_document" "allow_alb_loggin_access" {
count = var.enable_alb_access_logs ? 1 : 0
statement {
sid = "1"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.principle_account_id}:root"]
}
actions = [
"s3:PutObject",
]
resources = [
"arn:aws:s3:::${var.s3_log_bucket_name}/${var.s3_log_bucket_Key_name}/*",
]
}
}
resource "aws_s3_bucket" "log_bucket" {
count = var.enable_alb_access_logs ? 1 : 0
bucket = var.s3_log_bucket_name
acl = "private"
region = var.region
policy = data.aws_iam_policy_document.allow_alb_loggin_access[0].json
lifecycle_rule {
id = var.lifecycle_rule_id #required #default = ""
enabled = var.lifecycle_rule_enabled #default = false
prefix = var.lifecycle_rule_prefix #default = whole bucket
expiration {
days = var.lifecycle_rule_expiration #default = 90
}
}
}
resource "aws_s3_bucket_object" "concourse_alb_access_logs" {
count = var.enable_alb_access_logs ? 1 : 0
bucket = aws_s3_bucket.log_bucket[0].id
acl = "private"
key = "${var.s3_log_bucket_Key_name}/"
content = " "
}