cloudflare / terraform-provider-cloudflare

Cloudflare Terraform Provider
https://registry.terraform.io/providers/cloudflare/cloudflare
Mozilla Public License 2.0
786 stars 609 forks source link

Cloudflare_pages_project terraform resource deploy a page after creation #3099

Closed hndoss closed 7 months ago

hndoss commented 9 months ago

Current Terraform and Cloudflare provider version

Terraform v1.7.2 Cloudflare provider version 4.23.0

Description

After creating a Page project with the cloudflare_pages_project Terraform resource, the page can’t be accessed due to the following message "This project has not been deployed" when the static HTML is hosted in a Git repository. Can the provider also manage the first deployment?

Use cases

Potential Terraform configuration

I think it should be the default behavior. I mean, after creating a Page project in Cloudflare, is understandable that the user is expecting a deployed project instead of having to click a deploy button in the Cloudflare's console.

References

https://community.cloudflare.com/t/cloudflare-pages-project-terraform-resource-doesnt-deploy-a-page-after-creation/609016?u=hndoss

github-actions[bot] commented 9 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

savelichalex commented 8 months ago

Just want to post a workaround I did in my project

resource "null_resource" "deploy" {
  triggers = {
    always_run = "${timestamp()}"
  }

  provisioner "local-exec" {
    command = "cd ../app && envsubst < wrangler.template.toml > wrangler.toml && yarn build && yarn deploy --project-name $PROJECT_NAME"

    environment = {
      PROJECT_NAME = local.PROJECT_NAME
      CLOUDFLARE_ACCOUNT_ID = var.cloudflare_account_id
      PROJECT_KV_ID = cloudflare_workers_kv_namespace.app-kv-ns.id
      PROJECT_D1_NAME = local.D1_NAME
      PROJECT_D1_ID = cloudflare_d1_database.app-cms-db.id
      PROJECT_R2_NAME = local.R2_NAME
    }
  }
}
jacobbednarz commented 7 months ago

This issue has been closed as we are now tracking this internally with service teams directly. If you would like an update or to be notified when/if the product ships with this change, please reach out to Cloudflare Support or your account team who can watch the internal feature request for you.