-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3.tf
61 lines (52 loc) · 1.16 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
# --- AWS S3 ---
resource "aws_s3_bucket" "this" {
bucket = local.name_prefix
}
resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}
resource "aws_s3_bucket_acl" "this" {
depends_on = [
aws_s3_bucket_ownership_controls.this,
]
bucket = aws_s3_bucket.this.id
acl = "private"
}
resource "aws_s3_bucket_versioning" "this" {
bucket = aws_s3_bucket.this.id
versioning_configuration {
status = "Disabled"
}
}
resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
}
data "aws_iam_policy_document" "this" {
statement {
sid = "AllowVPCeAccessOnly"
effect = "Deny"
actions = [
"s3:GetObject",
"s3:PutObject"
]
resources = [
"arn:aws:s3:::${aws_s3_bucket.this.bucket}/*",
"arn:aws:s3:::${aws_s3_bucket.this.bucket}"
]
principals {
identifiers = ["*"]
type = "*"
}
condition {
test = "StringNotEquals"
variable = "aws:SourceVpce"
values = [
aws_vpc_endpoint.this.id
]
}
}
}