forked from segmentio/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
49 lines (36 loc) · 935 Bytes
/
main.tf
File metadata and controls
49 lines (36 loc) · 935 Bytes
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
variable "name" {}
variable "environment" {}
variable "account_id" {}
variable "logs_expiration_enabled" {
default = false
}
variable "logs_expiration_days" {
default = 30
}
data "aws_elb_service_account" "main" {}
data "template_file" "policy" {
template = "${file("${path.module}/policy.json")}"
vars = {
bucket = "${var.name}-${var.environment}-logs"
elb_account_id = "${data.aws_elb_service_account.main.arn}"
}
}
resource "aws_s3_bucket" "logs" {
bucket = "${var.name}-${var.environment}-logs"
lifecycle_rule {
id = "logs-expiration"
prefix = ""
enabled = "${var.logs_expiration_enabled}"
expiration {
days = "${var.logs_expiration_days}"
}
}
tags {
Name = "${var.name}-${var.environment}-logs"
Environment = "${var.environment}"
}
policy = "${data.template_file.policy.rendered}"
}
output "id" {
value = "${aws_s3_bucket.logs.id}"
}