-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
39 lines (32 loc) · 805 Bytes
/
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
resource "aws_s3_bucket" "main" {
bucket = "${var.application}.${lookup(var.env_dns_zones_prefix, terraform.workspace)}${var.domain}"
acl = "public-read"
website {
index_document = "index.html"
}
tags = {
Application = "${var.application}"
Environment = "${lookup(var.env_names, terraform.workspace)}"
Workspace = "${terraform.workspace}"
terraformed = "true"
}
}
data "aws_iam_policy_document" "main" {
statement {
effect = "Allow"
principals {
type = "AWS"
identifiers = ["*"]
}
actions = [
"s3:GetObject",
]
resources = [
"${aws_s3_bucket.main.arn}/*",
]
}
}
resource "aws_s3_bucket_policy" "main" {
bucket = "${aws_s3_bucket.main.id}"
policy = "${data.aws_iam_policy_document.main.json}"
}