-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudfront.tf
85 lines (71 loc) · 1.76 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
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
locals {
error_pages = [400, 403, 404, 405, 414, 416, 500, 501, 502, 503, 504]
}
resource "aws_route53_record" "live" {
count = var.using_cloudfront ? 1 : 0
zone_id = var.route_53_id
name = var.cloudfront_live_domain
type = "CNAME"
ttl = "300"
records = [aws_cloudfront_distribution.live[0].domain_name]
}
resource "aws_cloudfront_distribution" "live" {
count = var.using_cloudfront ? 1 : 0
enabled = true
comment = "Endpoint for medialive"
aliases = [var.cloudfront_live_domain]
viewer_certificate {
acm_certificate_arn = var.acm_certificate
ssl_support_method = "sni-only"
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
origin {
domain_name = "mediapackage.amazonaws.com"
origin_id = "TempORIGIN"
custom_origin_config {
http_port = 80
https_port = 443
origin_protocol_policy = "match-viewer"
origin_ssl_protocols = ["TLSv1"]
}
}
default_cache_behavior {
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "TempORIGIN"
viewer_protocol_policy = "redirect-to-https"
forwarded_values {
cookies {
forward = "none"
}
headers = [
"Access-Control-Request-Method",
"Access-Control-Request-Headers",
"Origin"
]
query_string = true
query_string_cache_keys = [
"end",
"m",
"start"
]
}
}
dynamic "custom_error_response" {
for_each = local.error_pages
content {
error_code = custom_error_response.value
error_caching_min_ttl = 1
}
}
lifecycle {
# ignore_changes = [
# origin
# ]
ignore_changes = all
}
}