Add channels.nixos.org cloudfront distribution
Eelco Dolstra committed
Mar 6, 2020 at 11:24 UTC
5e1be830ca1f3ca0146515501af2fe14e223089d
1 file changed
+63
terraform/channels.tf
+63
@@ -54,3 +54,66 @@ resource "aws_s3_bucket_policy" "channels" {
54
}
55
EOF
56
}
57
+
58
+resource "aws_cloudfront_distribution" "channels" {
59
+ enabled = true
60
+ is_ipv6_enabled = true
61
+ price_class = "PriceClass_All"
62
+ aliases = ["channels.nixos.org"]
63
+ default_root_object = "index.html"
64
+
65
+ origin {
66
+ origin_id = "default"
67
+ domain_name = "${aws_s3_bucket.channels.website_endpoint}"
68
+
69
+ custom_origin_config {
70
+ http_port = "80"
71
+ https_port = "443"
72
+ origin_protocol_policy = "http-only"
73
+ origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"]
74
+ }
75
+ }
76
+
77
+ default_cache_behavior {
78
+ viewer_protocol_policy = "redirect-to-https"
79
+ compress = true
80
+ allowed_methods = ["GET", "HEAD"]
81
+ cached_methods = ["GET", "HEAD"]
82
+ target_origin_id = "default"
83
+ min_ttl = 0
84
+ default_ttl = 60
85
+ max_ttl = 86400
86
+
87
+ forwarded_values {
88
+ query_string = false
89
+ cookies {
90
+ forward = "none"
91
+ }
92
+ }
93
+ }
94
+
95
+ viewer_certificate {
96
+ acm_certificate_arn = "${aws_acm_certificate.channels.arn}"
97
+ ssl_support_method = "sni-only"
98
+ }
99
+
100
+ restrictions {
101
+ geo_restriction {
102
+ restriction_type = "none"
103
+ }
104
+ }
105
+
106
+ logging_config {
107
+ bucket = "nix-cache-logs.s3.amazonaws.com"
108
+ }
109
+}
110
+
111
+resource "aws_acm_certificate" "channels" {
112
+ provider = "aws.us"
113
+ domain_name = "channels.nixos.org"
114
+ validation_method = "DNS"
115
+
116
+ lifecycle {
117
+ create_before_destroy = true
118
+ }
119
+}