page_title | subcategory | description |
---|---|---|
cloudflare_pages_project Resource - Cloudflare |
Provides a resource which manages Cloudflare Pages projects. |
Provides a resource which manages Cloudflare Pages projects.
-> If you are using a source
block configuration, you must first have a
connected GitHub or GitLab account connected to Cloudflare. See the
Getting Started with Pages documentation on how to link your accounts.
# Basic project
resource "cloudflare_pages_project" "basic_project" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "this-is-my-project-01"
production_branch = "main"
}
# Manage build config
resource "cloudflare_pages_project" "build_config" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "this-is-my-project-01"
production_branch = "main"
build_config {
build_command = "npm run build"
destination_dir = "build"
root_dir = "/"
web_analytics_tag = "cee1c73f6e4743d0b5e6bb1a0bcaabcc"
web_analytics_token = "021e1057c18547eca7b79f2516f06o7x"
}
}
# Manage project source
resource "cloudflare_pages_project" "source_config" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "this-is-my-project-01"
production_branch = "main"
source {
type = "github"
config {
owner = "cloudflare"
repo_name = "ninjakittens"
production_branch = "main"
pr_comments_enabled = true
deployments_enabled = true
production_deployment_enabled = true
preview_deployment_setting = "custom"
preview_branch_includes = ["dev", "preview"]
preview_branch_excludes = ["main", "prod"]
}
}
}
# Manage deployment configs
resource "cloudflare_pages_project" "deployment_configs" {
account_id = "f037e56e89293a057740de681ac9abbe"
name = "this-is-my-project-01"
production_branch = "main"
deployment_configs {
preview {
environment_variables = {
ENVIRONMENT = "preview"
}
kv_namespaces = {
KV_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3"
}
durable_object_namespaces = {
DO_BINDING = "5eb63bbbe01eeed093cb22bb8f5acdc3"
}
r2_buckets = {
R2_BINDING = "some-bucket"
}
d1_databases = {
D1_BINDING = "445e2955-951a-4358-a35b-a4d0c813f63"
}
compatibility_date = "2022-08-15"
compatibility_flags = ["preview_flag"]
}
production {
environment_variables = {
ENVIRONMENT = "production"
OTHER_VALUE = "other value"
}
kv_namespaces = {
KV_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3"
KV_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5"
}
durable_object_namespaces = {
DO_BINDING_1 = "5eb63bbbe01eeed093cb22bb8f5acdc3"
DO_BINDING_2 = "3cdca5f8bb22bc390deee10ebbb36be5"
}
r2_buckets = {
R2_BINDING_1 = "some-bucket"
R2_BINDING_2 = "other-bucket"
}
d1_databases = {
D1_BINDING_1 = "445e2955-951a-4358-a35b-a4d0c813f63"
D1_BINDING_2 = "a399414b-c697-409a-a688-377db6433cd9"
}
compatibility_date = "2022-08-16"
compatibility_flags = ["production_flag", "second flag"]
}
}
}
account_id
(String) The account identifier to target for the resource.name
(String) Name of the project.production_branch
(String) The name of the branch that is used for the production environment.
build_config
(Block List, Max: 1) Configuration for the project build process. (see below for nested schema)deployment_configs
(Block List, Max: 1) Configuration for deployments in a project. (see below for nested schema)source
(Block List, Max: 1) Configuration for the project source. (see below for nested schema)
created_on
(String) When the project was created.domains
(List of String) A list of associated custom domains for the project.id
(String) The ID of this resource.subdomain
(String) The Cloudflare subdomain associated with the project.
Optional:
build_command
(String) Command used to build project.destination_dir
(String) Output directory of the build.root_dir
(String) Directory to run the command.web_analytics_tag
(String) The classifying tag for analytics.web_analytics_token
(String) The auth token for analytics.
Optional:
preview
(Block List, Max: 1) Configuration for preview deploys. (see below for nested schema)production
(Block List, Max: 1) Configuration for production deploys. (see below for nested schema)
Optional:
compatibility_date
(String) Compatibility date used for Pages Functions.compatibility_flags
(List of String) Compatibility flags used for Pages Functions.d1_databases
(Map of String) D1 Databases used for Pages Functions.durable_object_namespaces
(Map of String) Durable Object namespaces used for Pages Functions.environment_variables
(Map of String) Environment variables for Pages Functions.kv_namespaces
(Map of String) KV namespaces used for Pages Functions.r2_buckets
(Map of String) R2 Buckets used for Pages Functions.
Optional:
compatibility_date
(String) Compatibility date used for Pages Functions.compatibility_flags
(List of String) Compatibility flags used for Pages Functions.d1_databases
(Map of String) D1 Databases used for Pages Functions.durable_object_namespaces
(Map of String) Durable Object namespaces used for Pages Functions.environment_variables
(Map of String) Environment variables for Pages Functions.kv_namespaces
(Map of String) KV namespaces used for Pages Functions.r2_buckets
(Map of String) R2 Buckets used for Pages Functions.
Optional:
config
(Block List, Max: 1) Configuration for the source of the Cloudflare Pages project. (see below for nested schema)type
(String) Project host type.
Required:
production_branch
(String) Project production branch name.
Optional:
deployments_enabled
(Boolean) Toggle deployments on this repo. Defaults totrue
.owner
(String) Project owner username.pr_comments_enabled
(Boolean) Enable Pages to comment on Pull Requests. Defaults totrue
.preview_branch_excludes
(List of String) Branches will be excluded from automatic deployment.preview_branch_includes
(List of String) Branches will be included for automatic deployment.preview_deployment_setting
(String) Preview Deployment Setting. Defaults toall
.production_deployment_enabled
(Boolean) Enable production deployments. Defaults totrue
.repo_name
(String) Project repository name.
Import is supported using the following syntax:
$ terraform import cloudflare_pages_project.example <account_id>/<project_name>