Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: error reading cloudflare pages project "...": required missing account ID #4783

Open
3 tasks done
itsdpao opened this issue Dec 16, 2024 · 2 comments
Open
3 tasks done
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.

Comments

@itsdpao
Copy link

itsdpao commented Dec 16, 2024

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

Terraform v1.10.2
on darwin_arm64

Affected resource(s)

cloudflare_pages_project

Terraform configuration files

resource "cloudflare_pages_project" "pages_project" {
  account_id = var.account_id
  name       = var.name

  production_branch = var.cloudflare_branch
}

resource "cloudflare_pages_domain" "pages_domain" {
  count        = length(var.custom_domains)
  account_id   = var.account_id
  project_name = resource.cloudflare_pages_project.pages_project.id
  domain       = var.custom_domains[count.index]
}

resource "cloudflare_record" "pages_record" {
  count   = length(var.custom_domains)
  name    = var.custom_domains[count.index]
  proxied = true
  ttl     = 1
  type    = "CNAME"
  value   = resource.cloudflare_pages_project.pages_project.subdomain
  zone_id = var.domain_zone_id
}

Link to debug output

https://gist.github.com/itsdpao/cd8de0e4f406553eb1847ea36fab31d0

Panic output

No response

Expected output

Successfully modify Cloudflare Pages project. In this case, I wanted to add a new subdomain, but I'm hitting this error instead.

Actual output

Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: error reading cloudflare pages project "dev-consumer-portal": required missing account ID
│
│   with module.pay.cloudflare_pages_project.pages_project,
│   on ../../../modules/pages/[main.tf](http://main.tf/) line 2, in resource "cloudflare_pages_project" "pages_project":
│    2: resource "cloudflare_pages_project" "pages_project" {
│
╵

Steps to reproduce

terraform plan

Additional factoids

I have a project that I'm trying to add a subdomain to. I was able to create the Cloudflare project previously using Terraform, but now I get an error output every time I run Terraform plan.

  1. Terraform & Cloudflare Provider Definition
terraform {
  required_version = ">= 1.10.2"
  required_providers {
  cloudflare = {
    source = "cloudflare/cloudflare"
    version = "~> 4.8"
  }
}
  1. Shared Cloudflare project module
    The module (located at "./modules/pages") that is shared amongst the other Cloudflare projects:
resource "cloudflare_pages_project" "pages_project" {
  account_id = var.account_id
  name = var.name
  production_branch = "main"
}

resource "cloudflare_pages_domain" "pages_domain" {
count = length(var.custom_domains)
account_id = var.account_id
project_name = resource.cloudflare_pages_project.pages_project.id
domain = var.custom_domains[count.index]
}

resource "cloudflare_record" "pages_record" {
  count = length(var.custom_domains)
  name = var.custom_domains[count.index]
  proxied = true
  ttl = 1
  type = "CNAME"
  value = resource.cloudflare_pages_project.pages_project.subdomain
  zone_id = var.domain_zone_id
}
  1. The Dev Environment that creates an instantiation of the module.

The caller of the module looks like this:

module "pay" {
  source = "./modules/pages"
  name = "some-portal"
  account_id = var.cloudflare_account_id
  cloudflare_branch = "master"
  custom_domains = ["portal.dev.something.com", "test.portal.dev.something.com"]
  domain_zone_id = var.cloudflare_zone_id
}

I have checked the Cloudflare Account Id and Cloudflare Zone Ids to be correct, and are properly set in the environment variables. Additionally, when I hardcode those values in the terraform module directly (and not pass them via ENV variables), it spits out the same error.

The weird thing is that this does not happen to any of the other Cloudflare Projects that use this exact same Terraform module. When a terraform plan is run on other projects, the terraform plan is successful. Only this particular project is having this issue. The terraform module code is exactly the same. Only the caller of the module is different with different variables passed in.

References

No response

@itsdpao itsdpao added kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 16, 2024
Copy link
Contributor

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added the triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log. label Dec 16, 2024
@itsdpao
Copy link
Author

itsdpao commented Dec 17, 2024

I found this #2430 and #2342 that was close to what I'm seeing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. triage/debug-log-attached Indicates an issue or PR has a complete Terraform debug log.
Projects
None yet
Development

No branches or pull requests

1 participant