-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
58 lines (46 loc) · 1.04 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
locals {
env = "local"
}
resource "aws_s3_bucket" "this" {
bucket = "my-tf-test-bucket-lpnu"
tags = {
Name = "My bucket"
Environment = "Dev"
}
}
resource "aws_s3_bucket" "this2" {
bucket = "my-tf-test-bucket-lpnu-2"
tags = {
Name = "My bucket"
Environment = local.env
}
}
module "s3_bucket_frontend" {
source = "terraform-aws-modules/s3-bucket/aws"
version = "3.9.0"
bucket = module.label.id
# acl = "private"
# control_object_ownership = true
# object_ownership = "ObjectWriter"
versioning = {
enabled = false
}
}
resource "aws_s3_bucket_policy" "this" {
bucket = module.s3_bucket_frontend.s3_bucket_id
policy = data.aws_iam_policy_document.this.json
}
data "aws_iam_policy_document" "this" {
statement {
principals {
type = "AWS"
identifiers = ["${module.cdn.cloudfront_origin_access_identity_iam_arns[0]}"]
}
actions = [
"s3:GetObject",
]
resources = [
"${module.s3_bucket_frontend.s3_bucket_arn}/*",
]
}
}