-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudfront.tf
More file actions
55 lines (46 loc) · 1.31 KB
/
cloudfront.tf
File metadata and controls
55 lines (46 loc) · 1.31 KB
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
locals {
s3_origin_id = "s3_origin"
}
resource "aws_cloudfront_distribution" "cloudfront" {
comment = "Created using terraform"
default_root_object = "index.html"
origin {
domain_name = aws_s3_bucket.s3_bucket.bucket_regional_domain_name
origin_id = local.s3_origin_id
origin_access_control_id = aws_cloudfront_origin_access_control.OAC.id
}
custom_error_response {
error_code = 403
response_code = 200
response_page_path = "/index.html"
}
default_cache_behavior {
allowed_methods = ["HEAD", "GET"]
cached_methods = ["HEAD", "GET"]
target_origin_id = local.s3_origin_id
viewer_protocol_policy = "allow-all"
compress = true
forwarded_values {
query_string = false
cookies {
forward = "none"
}
}
}
enabled = true
restrictions {
geo_restriction {
locations = []
restriction_type = "none"
}
}
viewer_certificate {
cloudfront_default_certificate = true
}
}
resource "aws_cloudfront_origin_access_control" "OAC" {
name = "s3_access_control"
origin_access_control_origin_type = "s3"
signing_behavior = "always"
signing_protocol = "sigv4"
}