-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage.tf
77 lines (65 loc) · 1.61 KB
/
storage.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
# Vault Storage Bucket
resource "aws_s3_bucket" "vault" {
bucket_prefix = "vault-vgh-"
acl = "private"
force_destroy = true
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
tags = var.common_tags
}
resource "aws_s3_bucket_policy" "vault" {
bucket = aws_s3_bucket.vault.id
policy = data.aws_iam_policy_document.vault_s3.json
}
data "aws_iam_policy_document" "vault_s3" {
statement {
sid = "DenyUnEncryptedInflightOperations"
effect = "Deny"
actions = ["s3:*"]
resources = ["arn:aws:s3:::${aws_s3_bucket.vault.id}/*"]
principals {
type = "*"
identifiers = ["*"]
}
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = [false]
}
}
statement {
sid = "DenyUnEncryptedObjectUploads"
effect = "Deny"
actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::${aws_s3_bucket.vault.id}/*"]
principals {
type = "*"
identifiers = ["*"]
}
condition {
test = "Null"
variable = "s3:x-amz-server-side-encryption"
values = ["true"]
}
}
statement {
sid = "DenyIncorrectEncryptionHeader"
effect = "Deny"
actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::${aws_s3_bucket.vault.id}/*"]
principals {
type = "*"
identifiers = ["*"]
}
condition {
test = "StringNotEquals"
variable = "s3:x-amz-server-side-encryption"
values = ["AES256", "aws:kms"]
}
}
}