This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path_cdn.tf
78 lines (63 loc) · 2.1 KB
/
_cdn.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
resource "aws_s3_bucket" "s3_bucket_logs" {
count = "${var.use_cloudfront != "false" ? 1 : 0}"
// If the bucket is marked for deletion, and is not empty, this forces it to be deleted
force_destroy = true
bucket = "${var.s3_bucket_for_cloudfront_logs}"
acl = "private"
}
resource "aws_cloudfront_distribution" "cdn" {
count = "${var.use_cloudfront != "false" ? 1 : 0}"
depends_on = ["aws_route53_record.internal-dns"]
aliases = ["${var.domain-name}", "${local.cdn_hostnames_aliases}"]
enabled = true
origin = {
domain_name = "${aws_route53_record.internal-dns.name}"
origin_id = "internal-dns"
custom_origin_config = {
http_port = 80
https_port = 443
origin_protocol_policy = "https-only"
origin_ssl_protocols = ["SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"]
}
}
logging_config = {
include_cookies = true
bucket = "${aws_s3_bucket.s3_bucket_logs.bucket_domain_name}"
prefix = "cnd-logs"
}
restrictions = {
geo_restriction = {
restriction_type = "none"
}
}
viewer_certificate = {
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1"
acm_certificate_arn = "${data.aws_acm_certificate.example.arn}"
}
tags = "${local.common_tags_cdn}"
default_cache_behavior = {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["HEAD", "GET", "OPTIONS"]
target_origin_id = "internal-dns"
forwarded_values = {
query_string = true
headers = ["Host", "X-Economist-Host", "incap-geo"]
cookies = {
forward = "whitelist"
whitelisted_names = [
"economist_amp_consent",
"economist_piano_id",
"economist_has_visited_app_before",
"ec_community",
"login_callback",
"geo_region"
]
}
}
min_ttl = 0
default_ttl = "${var.cfd_default_regular_ttl}"
max_ttl = "${var.cfd_default_max_ttl}"
viewer_protocol_policy = "redirect-to-https"
}
}