-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudfront.tf
46 lines (39 loc) · 1.38 KB
/
cloudfront.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
resource "aws_cloudfront_distribution" "cdn" {
enabled = true
default_root_object = "index.html"
price_class = "PriceClass_All"
aliases = [local.cdn_domain_name, local.wildcard_domain]
viewer_certificate {
acm_certificate_arn = aws_acm_certificate.main.arn
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.2_2019"
}
origin {
domain_name = aws_s3_bucket.bucket.website_endpoint
origin_id = local.cf_origin_id
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "http-only"
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
}
}
default_cache_behavior {
target_origin_id = local.cf_origin_id
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
viewer_protocol_policy = "allow-all"
cache_policy_id = "4135ea2d-6df8-44a3-9df3-4b5a84be39ad" # Managed-CachingDisabled
#origin_request_policy_id = "714055c8-34d7-44d0-9286-0019c2cf98b7" # CacheByHost
lambda_function_association {
event_type = "origin-request"
lambda_arn = aws_lambda_function.lambda_function.qualified_arn
include_body = false
}
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
}