Compare commits
No commits in common. '8ae8421722918c35dd9e71efd398707138af1343' and 'c9191e7e16d6beb602725169bf39f05ad219f623' have entirely different histories.
8ae8421722
...
c9191e7e16
@ -0,0 +1 @@
|
||||
use flake
|
||||
@ -1,4 +0,0 @@
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
.terraform/
|
||||
*.tfvars
|
||||
@ -1,16 +0,0 @@
|
||||
# CNAME record pointing vibebooks.elijah.run to the Cloudflare Pages subdomain.
|
||||
resource "cloudflare_record" "edu" {
|
||||
zone_id = var.cloudflare_zone_id
|
||||
name = "vibebooks"
|
||||
type = "CNAME"
|
||||
content = cloudflare_pages_project.edu.subdomain
|
||||
proxied = true
|
||||
}
|
||||
|
||||
# Bind the custom domain vibebooks.elijah.run to the Pages project.
|
||||
# Cloudflare provisions an SSL certificate automatically.
|
||||
resource "cloudflare_pages_domain" "edu" {
|
||||
account_id = var.cloudflare_account_id
|
||||
project_name = cloudflare_pages_project.edu.name
|
||||
domain = var.domain
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
terraform {
|
||||
# Local state — terraform.tfstate is gitignored.
|
||||
# No remote backend needed for this project.
|
||||
required_providers {
|
||||
# Cloudflare provider for Pages and DNS.
|
||||
cloudflare = {
|
||||
source = "registry.terraform.io/cloudflare/cloudflare"
|
||||
version = "~> 4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Cloudflare Pages project for the edu mdbook static site.
|
||||
# Deployment is handled via `wrangler pages deploy` from the CI/CD pipeline or justfile.
|
||||
# No git source block — artifact upload model only.
|
||||
resource "cloudflare_pages_project" "edu" {
|
||||
account_id = var.cloudflare_account_id
|
||||
name = "vibedbooks"
|
||||
production_branch = "main"
|
||||
|
||||
build_config {
|
||||
# mdbook build command — produces the static site in the `book/` directory.
|
||||
build_command = "mdbook build"
|
||||
destination_dir = "book"
|
||||
root_dir = "edu"
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
# The default Pages subdomain assigned by Cloudflare (e.g. vibedbooks.pages.dev).
|
||||
output "pages_subdomain" {
|
||||
description = "Cloudflare Pages auto-assigned subdomain for the edu site."
|
||||
value = cloudflare_pages_project.edu.subdomain
|
||||
}
|
||||
|
||||
# The production custom domain.
|
||||
output "production_url" {
|
||||
description = "Production URL for the edu site."
|
||||
value = "https://${var.domain}"
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
# Cloudflare provider configuration.
|
||||
# Authentication uses an API token passed via var.cloudflare_api_token.
|
||||
# Never hardcode credentials here — use TF_VAR_* env vars or a gitignored .tfvars file.
|
||||
provider "cloudflare" {
|
||||
api_token = var.cloudflare_api_token
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
# Cloudflare API token — required for all provider operations.
|
||||
# Set via: export TF_VAR_cloudflare_api_token="..."
|
||||
variable "cloudflare_api_token" {
|
||||
description = "Cloudflare API token with Pages and DNS edit permissions."
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
# Cloudflare account ID — required for Pages resources.
|
||||
# Set via: export TF_VAR_cloudflare_account_id="..."
|
||||
variable "cloudflare_account_id" {
|
||||
description = "Cloudflare account ID where edu resources are provisioned."
|
||||
type = string
|
||||
}
|
||||
|
||||
# Cloudflare zone ID for elijah.run — required for DNS records.
|
||||
# Set via: export TF_VAR_cloudflare_zone_id="..."
|
||||
variable "cloudflare_zone_id" {
|
||||
description = "Cloudflare zone ID for the elijah.run domain."
|
||||
type = string
|
||||
}
|
||||
|
||||
# Production domain for the edu site.
|
||||
variable "domain" {
|
||||
description = "Production domain where the edu site is hosted."
|
||||
type = string
|
||||
default = "vibebooks.elijah.run"
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
build:
|
||||
mdbook build
|
||||
|
||||
serve:
|
||||
mdbook serve
|
||||
|
||||
deploy:
|
||||
# Build the static site and upload it to Cloudflare Pages as a production deployment.
|
||||
# Requires CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID to be set in the environment.
|
||||
mdbook build
|
||||
wrangler pages deploy book --project-name vibedbooks --branch main
|
||||
|
||||
infra-init:
|
||||
# Initialise the OpenTofu working directory and download providers.
|
||||
cd infra && tofu init
|
||||
|
||||
infra-plan:
|
||||
# Preview infrastructure changes without applying them.
|
||||
cd infra && tofu plan
|
||||
|
||||
infra-apply:
|
||||
# Apply the OpenTofu configuration to Cloudflare.
|
||||
# Requires TF_VAR_cloudflare_api_token, TF_VAR_cloudflare_account_id, TF_VAR_cloudflare_zone_id.
|
||||
cd infra && tofu apply
|
||||
Loading…
Reference in New Issue