-
Notifications
You must be signed in to change notification settings - Fork 2
/
cloudfront.tf
71 lines (57 loc) · 1.87 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
resource "aws_cloudfront_origin_access_control" "this" {
name = "oac for ${var.panda_name}"
description = ""
origin_access_control_origin_type = "s3"
signing_behavior = "always"
signing_protocol = "sigv4"
}
resource "aws_cloudfront_distribution" "this" {
enabled = true
comment = "CDN for ${var.panda_name}"
default_root_object = "index.html"
aliases = [local.url]
price_class = "PriceClass_100"
origin {
domain_name = aws_s3_bucket.this.bucket_regional_domain_name
origin_id = aws_s3_bucket.this.bucket_regional_domain_name
origin_access_control_id = aws_cloudfront_origin_access_control.this.id
# custom_origin_config {
# http_port = 80
# https_port = 443
# origin_protocol_policy = "http-only"
# origin_ssl_protocols = ["TLSv1.2"]
# }
}
viewer_certificate {
acm_certificate_arn = aws_acm_certificate.this.arn
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1.2_2018"
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
default_cache_behavior {
allowed_methods = ["GET", "HEAD", "OPTIONS"]
cached_methods = ["GET", "HEAD"]
viewer_protocol_policy = "redirect-to-https"
target_origin_id = aws_s3_bucket.this.bucket_regional_domain_name
forwarded_values {
query_string = true
cookies {
forward = "none"
}
}
}
}
resource "aws_route53_record" "cloudfront_alias" {
zone_id = data.aws_route53_zone.this.zone_id
name = local.url
type = "A"
alias {
name = aws_cloudfront_distribution.this.domain_name
zone_id = aws_cloudfront_distribution.this.hosted_zone_id
evaluate_target_health = false
}
}