$ cat ./deployments/cloudflare-pages.md

Cloudflare Pages

Cloudflare Pages is an excellent choice for static sites or simple full-stack applications. Since this is a Go app, we might need to use Cloudflare Workers or deploy it as a container if we want the dynamic backend, OR we can compile the Go code to WebAssembly (Wasm) if we want to run it on the edge, but standard Cloudflare Pages is for static assets.

However, if we treat this as a static site generator (rendering HTML to disk), we can deploy directly to Pages.

Terraform for Cloudflare

We can automate the project creation with Terraform.

terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "~> 4.0"
    }
  }
}

provider "cloudflare" {
  api_token = var.cloudflare_api_token
}

resource "cloudflare_pages_project" "cv_website" {
  account_id        = var.cloudflare_account_id
  name              = "cv-website"
  production_branch = "main"
  
  source {
    type = "github"
    config {
      owner                         = "myuser"
      repo_name                     = "cv-website"
      production_deployment_enabled = true
    }
  }
}