-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudflare.tf
More file actions
91 lines (75 loc) · 2.29 KB
/
cloudflare.tf
File metadata and controls
91 lines (75 loc) · 2.29 KB
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
86
87
88
89
90
91
resource "cloudflare_workers_domain" "project_domain" {
account_id = var.cloudflare_account_id
hostname = "${var.project_name}.${var.environment}.${var.domain}"
service = "${var.project_name}-${var.environment}"
zone_id = var.cloudflare_zone_id
depends_on = [cloudflare_workers_script.project_script]
}
resource "cloudflare_workers_route" "project_route" {
zone_id = var.cloudflare_zone_id
pattern = "${var.project_name}.${var.environment}.${var.domain}/*"
script_name = cloudflare_workers_script.project_script.name
}
resource "cloudflare_workers_kv_namespace" "settings" {
account_id = var.cloudflare_account_id
title = "${var.project_name}-${var.environment}-settings"
}
resource "cloudflare_workers_script" "project_script" {
account_id = var.cloudflare_account_id
name = "${var.project_name}-${var.environment}"
content = file("${path.module}/dist/index.mjs")
compatibility_date = "2023-08-28"
module = true
kv_namespace_binding {
name = "SETTINGS"
namespace_id = cloudflare_workers_kv_namespace.settings.id
}
plain_text_binding {
name = "CORS_DOMAINS"
text = var.ALLOWED_HOSTS
}
plain_text_binding {
name = "DOMAIN"
text = var.domain
}
plain_text_binding {
name = "ENVIRONMENT"
text = var.environment
}
plain_text_binding {
name = "GCP_LOGGING_PROJECT_ID"
text = var.GCP_LOGGING_PROJECT_ID
}
plain_text_binding {
name = "GCP_BIGQUERY_PROJECT_ID"
text = var.GCP_BIGQUERY_PROJECT_ID
}
plain_text_binding {
name = "LOG_NAME"
text = "${var.project_name}_${var.environment}_worker_log"
}
plain_text_binding {
name = "VERSION"
text = var.VERSION
}
secret_text_binding {
name = "GCP_LOGGING_CREDENTIALS"
text = var.GCP_LOGGING_CREDENTIALS
}
secret_text_binding {
name = "GCP_BIGQUERY_CREDENTIALS"
text = var.GCP_BIGQUERY_CREDENTIALS
}
secret_text_binding {
name = "GCP_USERINFO_CREDENTIALS"
text = var.GCP_USERINFO_CREDENTIALS
}
secret_text_binding {
name = "GLOBAL_SHARED_SECRET"
text = var.GLOBAL_SHARED_SECRET
}
d1_database_binding {
name = "${var.project_name}_${var.environment}_cache"
database_id = "${data.local_file.load_api_gateway_cache_id.content}"
}
}