-
Notifications
You must be signed in to change notification settings - Fork 0
/
bucket_uploads.tf
93 lines (79 loc) · 1.9 KB
/
bucket_uploads.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#
# A bucket to which our app's in-browser javascript uploads files to be ingested, so the
# back-end app can get them. Should NOT be public. Needs CORS tags to allow JS upload.
#
resource "aws_s3_bucket" "uploads" {
bucket = "${local.name_prefix}-uploads"
lifecycle {
prevent_destroy = true
}
tags = {
"service" = local.service_tag
"use" = "upload"
"S3-Bucket-Name" = "${local.name_prefix}-uploads"
}
}
resource "aws_s3_bucket_public_access_block" "uploads" {
bucket = aws_s3_bucket.uploads.id
block_public_acls = true
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
}
resource "aws_s3_bucket_cors_configuration" "uploads" {
bucket = aws_s3_bucket.uploads.id
cors_rule {
allowed_headers = [
"Authorization",
"x-amz-date",
"x-amz-content-sha256",
"content-type",
]
allowed_methods = [
"GET",
"POST",
"PUT",
]
allowed_origins = [
"*",
]
expose_headers = [
"ETag",
]
max_age_seconds = 3000
}
}
resource "aws_s3_bucket_lifecycle_configuration" "uploads" {
bucket = aws_s3_bucket.uploads.id
rule {
status = "Enabled"
id = "Expire files"
expiration {
days = 30
expired_object_delete_marker = false
}
}
rule {
status = "Enabled"
id = "scihist-digicoll-${terraform.workspace}-uploads-IA-Rule"
transition {
days = 30
storage_class = "STANDARD_IA"
}
}
}
resource "aws_s3_bucket_versioning" "uploads" {
bucket = aws_s3_bucket.uploads.id
versioning_configuration {
status = "Disabled"
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "uploads" {
bucket = aws_s3_bucket.uploads.id
rule {
bucket_key_enabled = false
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}