forked from cloudposse/terraform-aws-ses-lambda-forwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths3.tf
61 lines (49 loc) · 1.74 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
resource "aws_s3_bucket" "default" {
#bridgecrew:skip=BC_AWS_S3_13:Skipping `Enable S3 Bucket Logging` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776).
#bridgecrew:skip=BC_AWS_S3_14:Skipping `Ensure all data stored in the S3 bucket is securely encrypted at rest` check until bridgecrew will support dynamic blocks (https://github.com/bridgecrewio/checkov/issues/776).
#bridgecrew:skip=CKV_AWS_52:Skipping `Ensure S3 bucket has MFA delete enabled` due to issue in terraform (https://github.com/hashicorp/terraform-provider-aws/issues/629).
bucket = module.this.id
force_destroy = true
versioning {
enabled = var.versioning_enabled
}
dynamic "logging" {
for_each = var.access_log_bucket_name != "" ? [1] : []
content {
target_bucket = var.access_log_bucket_name
target_prefix = "logs/${module.this.id}/"
}
}
dynamic "server_side_encryption_configuration" {
for_each = var.s3_bucket_encryption_enabled ? [1] : []
content {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
tags = module.this.tags
}
data "aws_iam_policy_document" "s3" {
statement {
sid = "GiveSESPermissionToWriteEmail"
effect = "Allow"
principals {
identifiers = ["ses.amazonaws.com"]
type = "Service"
}
actions = ["s3:PutObject"]
resources = ["${aws_s3_bucket.default.arn}/*"]
condition {
test = "StringEquals"
values = [data.aws_caller_identity.current.account_id]
variable = "aws:Referer"
}
}
}
resource "aws_s3_bucket_policy" "default" {
bucket = aws_s3_bucket.default.id
policy = data.aws_iam_policy_document.s3.json
}