linuxandy
linuxandy
CDCloudflare Developers
Created by linuxandy on 10/7/2023 in #pages-help
Deploying Cloudflare Pages site using Terraform
Good morning all. Apologies if I am using the wrong section for this question. New user only joined moments ago. Im trying to build a pages site using terraform. My code creates the pages project and settings, however it does not trigger a deployment. I was curious if anyone had this issue previously or have I just missed a config setting? Appreciate any advice please..I must have missed something in the docs.. If it helps this is my code:
resource "cloudflare_pages_project" "blog_pages_project" {
account_id = var.cloudflare_account_id
name = "blog"
production_branch = "main"

source {
type = "github"
config {
owner = "raveygravy"
repo_name = "blog"
production_branch = "main"
pr_comments_enabled = true
deployments_enabled = true
production_deployment_enabled = true
preview_deployment_setting = "all"
preview_branch_includes = ["*"]
preview_branch_excludes = ["main", "prod"]
}
}

build_config {
build_command = "hugo --gc --minify"
destination_dir = "public"
root_dir = ""
}

deployment_configs {
preview {
environment_variables = {
HUGO_VERSION = "0.118.2"
NODE_VERSION = "18.17.1"
}
fail_open = true
}
production {
environment_variables = {
HUGO_VERSION = "0.118.2"
NODE_VERSION = "18.17.1"
}
fail_open = true
}
}
}
resource "cloudflare_pages_project" "blog_pages_project" {
account_id = var.cloudflare_account_id
name = "blog"
production_branch = "main"

source {
type = "github"
config {
owner = "raveygravy"
repo_name = "blog"
production_branch = "main"
pr_comments_enabled = true
deployments_enabled = true
production_deployment_enabled = true
preview_deployment_setting = "all"
preview_branch_includes = ["*"]
preview_branch_excludes = ["main", "prod"]
}
}

build_config {
build_command = "hugo --gc --minify"
destination_dir = "public"
root_dir = ""
}

deployment_configs {
preview {
environment_variables = {
HUGO_VERSION = "0.118.2"
NODE_VERSION = "18.17.1"
}
fail_open = true
}
production {
environment_variables = {
HUGO_VERSION = "0.118.2"
NODE_VERSION = "18.17.1"
}
fail_open = true
}
}
}
6 replies