Skip to content

Commit 1b88cfb

Browse files
committed
feat: latest most minimal diff :D
1 parent 5bda132 commit 1b88cfb

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

infra/.terraform.lock.hcl

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/cdn/main.tf

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resource "fastly_service_vcl" "python_org" {
44
http3 = false
55
stale_if_error = false
66
stale_if_error_ttl = 43200
7-
activate = true
7+
activate = false
88

99
domain {
1010
name = var.domain
@@ -32,13 +32,14 @@ resource "fastly_service_vcl" "python_org" {
3232
connect_timeout = 1000
3333
first_byte_timeout = 30000
3434
between_bytes_timeout = 10000
35-
override_host = "www.python.org"
35+
override_host = var.subdomain == "test.python.org" ? "www.python.org" : null
3636
}
3737

3838
backend {
3939
name = "loadbalancer"
4040
address = "lb.nyc1.psf.io"
41-
shield = "iad-va-us"
41+
port = 20004
42+
shield = "lga-ny-us"
4243
healthcheck = "HAProxy Status"
4344
auto_loadbalance = false
4445
use_ssl = true
@@ -51,7 +52,7 @@ resource "fastly_service_vcl" "python_org" {
5152
connect_timeout = 1000
5253
first_byte_timeout = 15000
5354
between_bytes_timeout = 10000
54-
override_host = var.domain == "test.python.org" ? "www.python.org" : null
55+
override_host = var.subdomain == "test.python.org" ? "www.python.org" : null
5556
}
5657

5758
acl {
@@ -82,7 +83,7 @@ resource "fastly_service_vcl" "python_org" {
8283
condition {
8384
name = "HSTS w/ subdomains"
8485
priority = 10
85-
statement = "req.http.host == \"${var.domain}\""
86+
statement = "req.http.host == \"${var.subdomain}\""
8687
type = "RESPONSE"
8788
}
8889
condition {
@@ -191,7 +192,7 @@ resource "fastly_service_vcl" "python_org" {
191192
name = "www redirect"
192193
priority = 10
193194
response_condition = "apex redirect"
194-
source = "\"https://www.\" + req.http.host + req.url"
195+
source = "\"https://${var.subdomain}\" + req.url"
195196
type = "response"
196197
}
197198
header {
@@ -255,10 +256,10 @@ resource "fastly_service_vcl" "python_org" {
255256
name = "psf-fastly-logs"
256257
bucket_name = "psf-fastly-logs-eu-west-1"
257258
domain = "s3-eu-west-1.amazonaws.com"
258-
path = "/${replace(var.domain, ".", "-")}/%Y/%m/%d/"
259+
path = "/${replace(var.subdomain, ".", "-")}/%Y/%m/%d/"
259260
period = 3600
260261
gzip_level = 9
261-
format = "%%h \"%%{now}V\" %%l \"%%{req.request}V %%{req.url}V\" %%{req.proto}V %%>s %%{resp.http.Content-Length}V %%{resp.http.age}V \"%%{resp.http.x-cache}V\" \"%%{resp.http.x-cache-hits}V\" \"%%{req.http.content-type}V\" \"%%{req.http.accept-language}V\" \"%%{cstr_escape(req.http.user-agent)}V\""
262+
format = "%h \"%%{now}V\" %l \"%%{req.request}V %%{req.url}V\" %%{req.proto}V %>s %%{resp.http.Content-Length}V %%{resp.http.age}V \"%%{resp.http.x-cache}V\" \"%%{resp.http.x-cache-hits}V\" \"%%{req.http.content-type}V\" \"%%{req.http.accept-language}V\" \"%%{cstr_escape(req.http.user-agent)}V\""
262263
timestamp_format = "%Y-%m-%dT%H:%M:%S.000"
263264
redundancy = "standard"
264265
format_version = 2
@@ -271,7 +272,7 @@ resource "fastly_service_vcl" "python_org" {
271272
name = "syslog"
272273
address = "cdn-logs.nyc1.psf.io"
273274
port = 514
274-
format = "%%h \"%%{now}V\" %%l \"%%{req.request}V %%{req.url}V\" %%{req.proto}V %%>s %%{resp.http.Content-Length}V %%{resp.http.age}V \"%%{resp.http.x-cache}V\" \"%%{resp.http.x-cache-hits}V\" \"%%{req.http.content-type}V\" \"%%{req.http.accept-language}V\" \"%%{cstr_escape(req.http.user-agent)}V\""
275+
format = "%h \"%%{now}V\" %l \"%%{req.request}V %%{req.url}V\" %%{req.proto}V %>s %%{resp.http.Content-Length}V %%{resp.http.age}V \"%%{resp.http.x-cache}V\" \"%%{resp.http.x-cache-hits}V\" \"%%{req.http.content-type}V\" \"%%{req.http.accept-language}V\" \"%%{cstr_escape(req.http.user-agent)}V\""
275276
}
276277

277278
product_enablement {
@@ -296,15 +297,15 @@ resource "fastly_service_vcl" "python_org" {
296297

297298
response {
298299
content = <<-EOT
299-
<html>
300-
<head>
301-
<title>Too Many Requests</title>
302-
</head>
303-
<body>
304-
<p>Too Many Requests</p>
305-
</body>
306-
</html>
307-
EOT
300+
<html>
301+
<head>
302+
<title>Too Many Requests</title>
303+
</head>
304+
<body>
305+
<p>Too Many Requests</p>
306+
</body>
307+
</html>
308+
EOT
308309
content_type = "text/html"
309310
status = 429
310311
}
@@ -341,6 +342,4 @@ resource "fastly_service_vcl" "python_org" {
341342
response = "Forbidden"
342343
status = 403
343344
}
344-
345-
force_destroy = true
346345
}

infra/cdn/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ variable "domain" {
2525
type = string
2626
description = "The domain name of the service."
2727
}
28+
variable "subdomain" {
29+
type = string
30+
description = "The subdomain of the service."
31+
}
2832
variable "extra_domains" {
2933
type = list(string)
3034
description = "Extra domains to add to the service."

infra/main.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
module "fastly_production" {
22
source = "./cdn"
33

4-
name = "Python.org"
4+
name = "www.python.org"
55
domain = "python.org"
6+
subdomain = "www.python.org"
67
extra_domains = ["www.python.org"]
78
backend_address = "pythondotorg.ingress.us-east-2.psfhosted.computer"
89
default_ttl = 3600
@@ -18,7 +19,8 @@ module "fastly_staging" {
1819

1920
name = "test.python.org"
2021
domain = "test.python.org"
21-
extra_domains = []
22+
subdomain = "www.test.python.org"
23+
extra_domains = ["www.test.python.org"]
2224
# TODO: adjust to test-pythondotorg when done testing NGWAF
2325
backend_address = "pythondotorg.ingress.us-east-2.psfhosted.computer"
2426
default_ttl = 3600

0 commit comments

Comments
 (0)