create CloudFlare worker to host the go vanity page
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
6dd007e48b
commit
95192fff5f
|
@ -0,0 +1,40 @@
|
|||
/* Providers ---------------------------------------------*/
|
||||
|
||||
provider "cloudflare" {
|
||||
email = var.cloudflare_email
|
||||
token = var.cloudflare_token
|
||||
org_id = var.cloudflare_org_id
|
||||
}
|
||||
|
||||
/* Locals ------------------------------------------------*/
|
||||
|
||||
locals {
|
||||
fqdn = "${var.subdomain}.${var.domain}"
|
||||
}
|
||||
|
||||
/* Resources ---------------------------------------------*/
|
||||
|
||||
/* This JS script generats the Website from list of repos */
|
||||
resource "cloudflare_worker_script" "vanity" {
|
||||
name = "go-status-im-vanity"
|
||||
content = "${file("go_vanity.js")}"
|
||||
}
|
||||
|
||||
/* Handle all requests to configured subdomain with the script */
|
||||
resource "cloudflare_worker_route" "vanity" {
|
||||
zone = var.domain
|
||||
pattern = "${local.fqdn}/*"
|
||||
|
||||
script_name = cloudflare_worker_script.vanity.name
|
||||
depends_on = [cloudflare_worker_script.vanity]
|
||||
}
|
||||
|
||||
/* DNS Entry */
|
||||
resource "cloudflare_record" "vanity" {
|
||||
domain = var.domain
|
||||
name = var.subdomain
|
||||
type = "CNAME"
|
||||
proxied = true
|
||||
/* value doesn't matter, worker handles it */
|
||||
value = "golang.org"
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* CloudFlare Credentials --------------------------------*/
|
||||
|
||||
variable "cloudflare_token" {
|
||||
description = "Token for interacting with Cloudflare API."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "cloudflare_email" {
|
||||
description = "Email address of Cloudflare account."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "cloudflare_org_id" {
|
||||
description = "ID of the CloudFlare organization."
|
||||
type = string
|
||||
}
|
||||
|
||||
/* General -----------------------------------------------*/
|
||||
|
||||
variable "domain" {
|
||||
description = "Domain to be used for Go packages vanity."
|
||||
type = string
|
||||
default = "status.im"
|
||||
}
|
||||
|
||||
variable "subdomain" {
|
||||
description = "Subdomain of the domain to be used for Go vanity."
|
||||
type = string
|
||||
default = "go"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
terraform {
|
||||
required_version = ">= 0.12"
|
||||
}
|
Loading…
Reference in New Issue