This repository was archived by the owner on Jan 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.tf
85 lines (74 loc) · 1.98 KB
/
main.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
variable "origin_domain_name" {}
variable "origin_id" {}
variable "alias" {}
variable "acm_certificate_arn" {}
variable "origin_path" {
default = ""
}
variable "origin_http_port" {
default = 80
}
variable "origin_https_port" {
default = 443
}
variable "distribution_enabled" {
default = true
}
variable "comment" {
default = ""
}
variable "default_root_object" {
default = "index.html"
}
variable "compression" {
default = false
}
variable "custom_error_response" {
type = "list"
default = []
}
resource "aws_cloudfront_distribution" "ssl_distribution" {
origin {
domain_name = "${var.origin_domain_name}"
origin_id = "${var.origin_id}"
origin_path = "${var.origin_path}"
custom_origin_config {
http_port = "${var.origin_http_port}"
https_port = "${var.origin_https_port}"
origin_protocol_policy = "https-only" # Only talk to the origin over HTTPS
origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
}
}
enabled = "${var.distribution_enabled}"
comment = "${var.comment}"
default_root_object = "${var.default_root_object}"
aliases = ["${var.alias}"]
price_class = "PriceClass_200"
default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "${var.origin_id}"
compress = "${var.compression}"
forwarded_values {
query_string = false
cookies {
forward = "none"
}
}
viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 360
max_ttl = 3600
}
restrictions {
geo_restriction {
restriction_type = "none"
}
}
viewer_certificate {
acm_certificate_arn = "${var.acm_certificate_arn}"
ssl_support_method = "sni-only"
minimum_protocol_version = "TLSv1"
}
custom_error_response = ["${var.custom_error_response}"]
}