use terraform & github actions
This commit is contained in:
1 parent
c275813d97
commit
4f18b3fd66
9 files changed
+2870
-2714
No files matched your search
@@ -0,0 +1,59 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
cloudflare = {
|
||||
source = "cloudflare/cloudflare"
|
||||
version = "~> 4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "cloudflare" {
|
||||
# read token from $CLOUDFLARE_API_TOKEN
|
||||
}
|
||||
|
||||
variable "CLOUDFLARE_ACCOUNT_ID" {
|
||||
# read account id from $TF_VAR_CLOUDFLARE_ACCOUNT_ID
|
||||
type = string
|
||||
}
|
||||
|
||||
resource "cloudflare_workers_kv_namespace" "uptimeflare_kv" {
|
||||
account_id = var.CLOUDFLARE_ACCOUNT_ID
|
||||
title = "uptimeflare_kv"
|
||||
}
|
||||
|
||||
resource "cloudflare_worker_script" "uptimeflare" {
|
||||
account_id = var.CLOUDFLARE_ACCOUNT_ID
|
||||
name = "uptimeflare_worker"
|
||||
content = file("worker/dist/index.js")
|
||||
module = true
|
||||
compatibility_date = "2023-11-08"
|
||||
|
||||
kv_namespace_binding {
|
||||
name = "UPTIMEFLARE_STATE"
|
||||
namespace_id = cloudflare_workers_kv_namespace.uptimeflare_kv.id
|
||||
}
|
||||
}
|
||||
|
||||
resource "cloudflare_worker_cron_trigger" "uptimeflare_worker_cron" {
|
||||
account_id = var.CLOUDFLARE_ACCOUNT_ID
|
||||
script_name = cloudflare_worker_script.uptimeflare.name
|
||||
schedules = [
|
||||
"*/2 * * * *", # every 2 minutes
|
||||
]
|
||||
}
|
||||
|
||||
resource "cloudflare_pages_project" "uptimeflare" {
|
||||
account_id = var.CLOUDFLARE_ACCOUNT_ID
|
||||
name = "uptimeflare"
|
||||
production_branch = "main"
|
||||
|
||||
deployment_configs {
|
||||
production {
|
||||
kv_namespaces = {
|
||||
UPTIMEFLARE_STATE = cloudflare_workers_kv_namespace.uptimeflare_kv.id
|
||||
}
|
||||
compatibility_date = "2023-11-08"
|
||||
compatibility_flags = ["nodejs_compat"]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user