Skip to content

Commit fef55f2

Browse files
committed
enable cloudflare proxy to api.haxe.org
1 parent 028b181 commit fef55f2

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

aws-ssm.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ data "aws_ssm_parameter" "gandi_personal_access_token" {
33
}
44

55
# haxe-terraform API token summary
6-
# Haxe - Workers R2 SQL:Read, Workers R2 Data Catalog:Edit, Workers R2 Storage:Edit
7-
# haxe.org - Zone Settings:Edit, DNS:Edit
6+
# Haxe - Workers R2 SQL:Read, Workers R2 Data Catalog:Edit, Workers R2 Storage:Edit, Account Rulesets:Edit
7+
# haxe.org - DNS Settings:Edit, Config Rules:Edit, Cache Rules:Edit, Origin Rules:Edit, Transform Rules:Edit, Zone Settings:Edit, DNS:Edit
88
data "aws_ssm_parameter" "cloudflare_api_token" {
99
name = "cloudflare_api_token"
1010
}

cloudflare.tf

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,40 @@ resource "cloudflare_zone_setting" "ssl" {
1515
value = "strict" # Options: "off", "flexible", "full", "strict"
1616
}
1717

18+
# Cache rule configuring cache settings and defining custom cache keys
19+
resource "cloudflare_ruleset" "cache_rules" {
20+
zone_id = local.cloudflare.zones.haxe-org.zone_id
21+
name = "Set cache settings"
22+
description = "Set cache settings for incoming requests"
23+
kind = "zone"
24+
phase = "http_request_cache_settings"
25+
26+
rules = [
27+
{
28+
ref = "api-haxe-org-cache-rule"
29+
description = "Set cache settings for api.haxe.org"
30+
expression = "(http.host eq \"api.haxe.org\")"
31+
enabled = true
32+
action = "set_cache_settings"
33+
action_parameters = {
34+
cache = true
35+
edge_ttl = {
36+
mode = "respect_origin"
37+
status_code_ttl = [
38+
{
39+
status_code_range = {
40+
from = 200
41+
to = 399
42+
}
43+
value = 60 * 60 * 24 * 1 # 1 day
44+
}
45+
]
46+
}
47+
}
48+
}
49+
]
50+
}
51+
1852
resource "cloudflare_dns_record" "acm-haxe-org-us-east-1-dns" {
1953
for_each = {
2054
for dvo in aws_acm_certificate.haxe-org-us-east-1-dns.domain_validation_options :
@@ -94,7 +128,8 @@ resource "cloudflare_dns_record" "api-haxe-org" {
94128
name = "api"
95129
type = "CNAME"
96130
content = module.cloudfront_api-haxe-org.cloudfront_distribution_domain_name
97-
ttl = 86400
131+
ttl = 1
132+
proxied = true
98133
}
99134

100135
resource "cloudflare_dns_record" "benchs-haxe-org" {

0 commit comments

Comments
 (0)