generated from GSA/grace-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
s3.tf
53 lines (44 loc) · 1.03 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
locals {
useAccessLogging = length(var.access_logging_bucket) > 0 ? [1] : []
}
#tfsec:ignore:AWS002
resource "aws_s3_bucket" "bucket" {
bucket = local.app_name
acl = "private"
force_destroy = true
versioning {
enabled = true
}
dynamic "logging" {
for_each = local.useAccessLogging
content {
target_bucket = var.access_logging_bucket
target_prefix = "${local.app_name}-logs/"
}
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
kms_master_key_id = aws_kms_key.kms_key.arn
sse_algorithm = "aws:kms"
}
}
}
lifecycle_rule {
id = "delete"
enabled = true
expiration {
days = 7
}
}
tags = {
Name = "${upper(var.project_name)} Inventory Report"
}
}
resource "aws_s3_bucket_public_access_block" "bucket" {
bucket = aws_s3_bucket.bucket.id
block_public_acls = true
ignore_public_acls = true
block_public_policy = true
restrict_public_buckets = true
}