-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathterraform.tf
42 lines (34 loc) · 893 Bytes
/
terraform.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
provider "aws" {
region = "${var.region}"
}
resource "aws_s3_bucket" "default" {
bucket = "${var.bucket}"
acl = "public-read"
force_destroy = "${var.force_destroy}"
logging {
target_bucket = "${aws_s3_bucket.logs.bucket}"
}
website {
index_document = "${var.index_document}"
error_document = "${var.error_document}"
}
}
resource "aws_s3_bucket_policy" "default" {
bucket = "${aws_s3_bucket.default.id}"
policy = "${data.aws_iam_policy_document.default.json}"
}
data "aws_iam_policy_document" "default" {
statement {
actions = ["s3:GetObject"]
resources = ["${aws_s3_bucket.default.arn}/*"]
principals {
type = "AWS"
identifiers = ["*"]
}
}
}
resource "aws_s3_bucket" "logs" {
bucket = "${var.bucket}-logs"
acl = "log-delivery-write"
force_destroy = "${var.force_destroy}"
}