-
Notifications
You must be signed in to change notification settings - Fork 4
/
aws_s3_bucket.website.tf
75 lines (62 loc) · 1.65 KB
/
aws_s3_bucket.website.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
# tfsec:ignore:AWS017
resource "aws_s3_bucket" "website" {
# checkov:skip=CKV_AWS_18: v4 legacy
# checkov:skip=CKV2_AWS_40: Its a website
# checkov:skip=CKV2_AWS_6: ADD REASON
# checkov:skip=CKV_AWS_144: Its a website
# checkov:skip=CKV_AWS_145: Its a website
# checkov:skip=CKV_AWS_19: "Ensure all data stored in the S3 bucket is securely encrypted at rest"
# checkov:skip=CKV_AWS_21: "Ensure all data stored in the S3 bucket have versioning enabled"
# checkov:skip=CKV_AWS_52: "Ensure S3 bucket has MFA delete enabled"
bucket = var.bucket_name
force_destroy = var.force_destroy
tags = var.common_tags
}
resource "aws_s3_bucket_acl" "website" {
bucket = aws_s3_bucket.website.bucket
acl = "private"
}
resource "aws_s3_bucket_website_configuration" "website" {
bucket = aws_s3_bucket.website.bucket
index_document {
suffix = "index.html"
}
error_document {
key = "error.html"
}
routing_rule {
condition {
key_prefix_equals = "docs/"
}
redirect {
replace_key_prefix_with = "documents/"
}
}
}
resource "aws_s3_bucket_logging" "website" {
bucket = aws_s3_bucket.website.id
target_bucket = aws_s3_bucket.logging.id
target_prefix = "log/"
}
resource "aws_s3_bucket_versioning" "website" {
bucket = aws_s3_bucket.website.id
versioning_configuration {
status = var.versioning
}
}
resource "aws_s3_bucket_cors_configuration" "website" {
bucket = aws_s3_bucket.website.bucket
cors_rule {
allowed_headers = [
"Authorization",
]
allowed_methods = [
"GET",
]
allowed_origins = [
"*",
]
expose_headers = []
max_age_seconds = 3000
}
}