@cryptotaxi247 / infra / commits / 3017c403

terraform: create Fastly CDN for tarballs.nixos.org

zimbatm committed Dec 16, 2018 at 14:01 UTC 3017c403f9e36caeeb7f5b9c74e538a393a35249
1 file changed +46
terraform/nixpkgs-tarballs-fastly.tf new
+46
@@ -0,0 +1,46 @@
1 +locals {
2 + # The aws_s3_bucket resource returns an unknown domain
3 + #tarballs_backend = "${lower(aws_s3_bucket.nixpkgs-tarballs.website_endpoint)}"
4 + tarballs_backend = "nixpkgs-tarballs.s3-website-eu-west-1.amazonaws.com"
5 +
6 + tarballs_domain = "tarballs.nixos.org"
7 +}
8 +
9 +resource "fastly_service_v1" "nixpkgs-tarballs" {
10 + name = "nixpkgs-tarballs"
11 + force_destroy = true
12 + default_host = "${local.tarballs_backend}"
13 +
14 + domain {
15 + name = "${local.tarballs_domain}"
16 + }
17 +
18 + backend {
19 + address = "${local.tarballs_backend}"
20 + name = "AWS S3 website"
21 +
22 + # S3 websites don't binds on port 443
23 + port = 80
24 + }
25 +
26 + # Clean headers for caching
27 +
28 + header {
29 + destination = "http.x-amz-request-id"
30 + type = "cache"
31 + action = "delete"
32 + name = "remove x-amz-request-id"
33 + }
34 + header {
35 + destination = "http.x-amz-version-id"
36 + type = "cache"
37 + action = "delete"
38 + name = "remove x-amz-version-id"
39 + }
40 + header {
41 + destination = "http.x-amz-id-2"
42 + type = "cache"
43 + action = "delete"
44 + name = "remove x-amz-id-2"
45 + }
46 +}