-
Notifications
You must be signed in to change notification settings - Fork 1
/
buckets.tf
41 lines (41 loc) · 1009 Bytes
/
buckets.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
## Bucket for domain.com
resource "aws_s3_bucket" "primary_s3bucket" {
bucket = var.SITENAME
acl = "public-read"
policy = file("PUBLIC-bucket-policy.json")
force_destroy = true
# setup static website
website {
index_document = "index.html"
error_document = "error.html"
}
logging {
target_bucket = aws_s3_bucket.logs_s3bucket.id
}
}
## Bucket for www.domain.com
resource "aws_s3_bucket" "www_s3bucket" {
bucket = "www.${var.SITENAME}"
acl = "public-read"
depends_on = [aws_s3_bucket.primary_s3bucket]
force_destroy = true
# setup www.domain.com static website
website {
redirect_all_requests_to = var.SITENAME
}
}
## bucket for site logs
resource "aws_s3_bucket" "logs_s3bucket" {
bucket = "logs.${var.SITENAME}"
acl = "log-delivery-write"
# force destroy bucket, in case logs are present.
force_destroy = true
# setup lifecycle management for logs.
lifecycle_rule {
id = "log"
enabled = true
expiration {
days = 90
}
}
}