Confirmation
Terraform and Cloudflare provider version
Terraform v1.14.6
on darwin_arm64
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 5.18.0"
}
Affected resource(s)
Terraform configuration files
resource "cloudflare_worker" "branding_web" {
account_id = var.cloudflare_account_id
name = "my-worker"
observability = {
enabled = true
logs = { enabled = true }
}
}
Link to debug output
https://gist.github.com/heiba/0be646eefcf3e8d7f7968861a934513e
Panic output
No response
Expected output
After creating a Worker via Terraform, I should be able to specify a GitHub repository, branch, and build/deploy commands so that the Worker is automatically connected to Git for Workers Builds. The Git connection should show as connected in Settings > Builds > Git repository in the dashboard, and pushes to the configured branch should trigger automated builds and deployments.
The cloudflare_worker resource (or a companion resource) should support something like:
resource "cloudflare_worker" "branding_web" {
account_id = var.cloudflare_account_id
name = "my-worker"
# Git integration for Workers Builds
builds = {
provider_type = "github"
provider_account_name = "my-org"
provider_account_id = "12345678"
repo_name = "my-worker-repo"
repo_id = "87654321"
branch = "main"
build_command = "npm run build"
deploy_command = "npx wrangler deploy"
}
}
This is consistent with how cloudflare_pages_project handles Git integration via its source block — the expectation is that Workers should have parity.
Actual output
The Worker is created successfully, but there is no way to connect it to a Git repository through Terraform. After terraform apply, the Worker's Settings > Builds > Git repository still shows "Connect" with no repository linked:
Workers Builds Git repository shows "Connect" — not connected after Terraform apply
The Git integration can only be completed by:
- Manually clicking "Connect" in the Cloudflare dashboard, or
- Using
terraform_data with local-exec provisioners that shell out to curl against the undocumented-in-Terraform Builds API — which does not track state, cannot detect drift, is not idempotent, and requires curl/jq as runtime dependencies.
This means the Git connection is the only part of the Worker setup that cannot be managed via Terraform, breaking the IaC workflow.
Steps to reproduce
- Create a
cloudflare_worker resource via Terraform
- Run
terraform apply — Worker is created successfully
- Open the Worker in the Cloudflare dashboard → Settings > Builds
- Observe that Git repository is not connected — it shows "Connect"
- The only way to connect it is manually via the dashboard or raw API calls
Additional factoids
- The Builds API fully supports managing this programmatically (tokens, repo connections, triggers), but the Terraform provider does not expose any of it.
cloudflare_pages_project already supports Git integration via its source block. Workers Builds is the Workers-side equivalent and should have the same Terraform support.
- The Workers IaC documentation covers
cloudflare_worker, cloudflare_worker_version, and cloudflare_workers_deployment but makes no mention of Workers Builds or Git integration.
References
No response
Confirmation
Terraform and Cloudflare provider version
Affected resource(s)
cloudflare_workerTerraform configuration files
Link to debug output
https://gist.github.com/heiba/0be646eefcf3e8d7f7968861a934513e
Panic output
No response
Expected output
After creating a Worker via Terraform, I should be able to specify a GitHub repository, branch, and build/deploy commands so that the Worker is automatically connected to Git for Workers Builds. The Git connection should show as connected in Settings > Builds > Git repository in the dashboard, and pushes to the configured branch should trigger automated builds and deployments.
The
cloudflare_workerresource (or a companion resource) should support something like:This is consistent with how
cloudflare_pages_projecthandles Git integration via itssourceblock — the expectation is that Workers should have parity.Actual output
The Worker is created successfully, but there is no way to connect it to a Git repository through Terraform. After
terraform apply, the Worker's Settings > Builds > Git repository still shows "Connect" with no repository linked:Workers Builds Git repository shows "Connect" — not connected after Terraform apply
The Git integration can only be completed by:
terraform_datawithlocal-execprovisioners that shell out tocurlagainst the undocumented-in-Terraform Builds API — which does not track state, cannot detect drift, is not idempotent, and requirescurl/jqas runtime dependencies.This means the Git connection is the only part of the Worker setup that cannot be managed via Terraform, breaking the IaC workflow.
Steps to reproduce
cloudflare_workerresource via Terraformterraform apply— Worker is created successfullyAdditional factoids
cloudflare_pages_projectalready supports Git integration via itssourceblock. Workers Builds is the Workers-side equivalent and should have the same Terraform support.cloudflare_worker,cloudflare_worker_version, andcloudflare_workers_deploymentbut makes no mention of Workers Builds or Git integration.References
No response