-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
90 lines (75 loc) · 2.02 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# aws_s3_bucket
resource "aws_s3_bucket" "web_bucket" {
bucket = local.s3_bucket_name
force_destroy = true
tags = local.common_tags
}
# aws_s3_bucket_policy
resource "aws_s3_bucket_policy" "web_bucket" {
bucket = aws_s3_bucket.web_bucket.id
policy = jsonencode(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Principal" : {
"AWS" : "${data.aws_elb_service_account.root.arn}"
},
"Action" : "s3:PutObject",
"Resource" : "arn:aws:s3:::${local.s3_bucket_name}/alb-logs/*"
},
{
"Effect" : "Allow",
"Principal" : {
"Service" : "delivery.logs.amazonaws.com"
},
"Action" : "s3:PutObject",
"Resource" : "arn:aws:s3:::${local.s3_bucket_name}/alb-logs/*",
"Condition" : {
"StringEquals" : {
"s3:x-amz-acl" : "bucket-owner-full-control"
}
}
},
{
"Effect" : "Allow",
"Principal" : {
"Service" : "delivery.logs.amazonaws.com"
},
"Action" : "s3:GetBucketAcl",
"Resource" : "arn:aws:s3:::${local.s3_bucket_name}"
}
]
})
}
# policy = data.aws_iam_policy_document.allow_access.json
# data "aws_iam_policy_document" "allow_access" {
# statement {
# principals {
# type = "AWS"
# identifiers = ["123456789012"]
# }
# actions = [
# "s3:GetObject",
# "s3:ListBucket",
# ]
# resources = [
# aws_s3_bucket.example.arn,
# "${aws_s3_bucket.example.arn}/*",
# ]
# }
# }
# aws_s3_object
resource "aws_s3_object" "website" {
bucket = aws_s3_bucket.web_bucket.bucket
key = "/website/index.html"
source = "./website/index.html"
tags = local.common_tags
}
resource "aws_s3_object" "graphic" {
bucket = aws_s3_bucket.web_bucket.bucket
key = "/website/Globo_logo_Vert.png"
source = "./website/Globo_logo_Vert.png"
tags = local.common_tags
}