@msl make sure your api key has all the access it needs?

@msl make sure your api key has all the access it needs?
13 Replies
Sir 2BD
Sir 2BD•3mo ago
Hey all! Has anyone had any success using the Cloudflare Terraform provider to create Pages projects? Whenever I run my Terraform code, I seem to receive the following error
{"@level":"info","@message":"cloudflare_pages_project.landing_cloudflare_pages_project: Creation errored after 16s","@module":"terraform.ui","@timestamp":"2024-10-14T17:39:10.001183Z","hook":{"resource":{"addr":"cloudflare_pages_project.landing_cloudflare_pages_project","module":"","resource":"cloudflare_pages_project.landing_cloudflare_pages_project","implied_provider":"cloudflare","resource_type":"cloudflare_pages_project","resource_name":"landing_cloudflare_pages_project","resource_key":null},"action":"create","elapsed_seconds":16},"type":"apply_errored"}
{"@level":"error","@message":"Error: error creating cloudflare pages project \"ceres-landing-dev\": received internal server error response (HTTP 500), please try again later","@module":"terraform.ui","@timestamp":"2024-10-14T17:39:10.768396Z","diagnostic":{"severity":"error","summary":"error creating cloudflare pages project \"ceres-landing-dev\": received internal server error response (HTTP 500), please try again later","detail":"","address":"cloudflare_pages_project.landing_cloudflare_pages_project","range":{"filename":"main.tf","start":{"line":21,"column":72,"byte":372},"end":{"line":21,"column":73,"byte":373}},"snippet":{"context":"resource \"cloudflare_pages_project\" \"landing_cloudflare_pages_project\"","code":"resource \"cloudflare_pages_project\" \"landing_cloudflare_pages_project\" {","start_line":21,"highlight_start_offset":71,"highlight_end_offset":72,"values":[]}},"type":"diagnostic"}****
{"@level":"info","@message":"cloudflare_pages_project.landing_cloudflare_pages_project: Creation errored after 16s","@module":"terraform.ui","@timestamp":"2024-10-14T17:39:10.001183Z","hook":{"resource":{"addr":"cloudflare_pages_project.landing_cloudflare_pages_project","module":"","resource":"cloudflare_pages_project.landing_cloudflare_pages_project","implied_provider":"cloudflare","resource_type":"cloudflare_pages_project","resource_name":"landing_cloudflare_pages_project","resource_key":null},"action":"create","elapsed_seconds":16},"type":"apply_errored"}
{"@level":"error","@message":"Error: error creating cloudflare pages project \"ceres-landing-dev\": received internal server error response (HTTP 500), please try again later","@module":"terraform.ui","@timestamp":"2024-10-14T17:39:10.768396Z","diagnostic":{"severity":"error","summary":"error creating cloudflare pages project \"ceres-landing-dev\": received internal server error response (HTTP 500), please try again later","detail":"","address":"cloudflare_pages_project.landing_cloudflare_pages_project","range":{"filename":"main.tf","start":{"line":21,"column":72,"byte":372},"end":{"line":21,"column":73,"byte":373}},"snippet":{"context":"resource \"cloudflare_pages_project\" \"landing_cloudflare_pages_project\"","code":"resource \"cloudflare_pages_project\" \"landing_cloudflare_pages_project\" {","start_line":21,"highlight_start_offset":71,"highlight_end_offset":72,"values":[]}},"type":"diagnostic"}****
Tl;dr here seems to be a mysterious 500 error from the API server with no discernable message about what went wrong. Additionally, I'm pretty sure it's not a permissions issue, as I created a key that has every single edit permission in order to test if perms were the issue. My Terraform code seems to be correct and didn't fail validation:
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.43.0"
}
}
}

provider "cloudflare" {
api_client_logging = true
api_token = var.cloudflare_api_token
}

resource "cloudflare_pages_project" "landing_cloudflare_pages_project" {
account_id = var.cloudflare_account_id
name = "ceres-landing-${var.environment_name}"
production_branch = "main"
}
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.43.0"
}
}
}

provider "cloudflare" {
api_client_logging = true
api_token = var.cloudflare_api_token
}

resource "cloudflare_pages_project" "landing_cloudflare_pages_project" {
account_id = var.cloudflare_account_id
name = "ceres-landing-${var.environment_name}"
production_branch = "main"
}
If anyone's seen this error before / sees any super obvious configuration issues, definitely let me know, I've been on this for like two days and am completely stumped 😭
Walshy
Walshy•3mo ago
what's your account id? and could you share your tf debug logs?
Sir 2BD
Sir 2BD•3mo ago
Account ID is accbefee9c471e18e859930cfbe64300, full TF Cloud logs are attached to this message. Thank you!!!
Walshy
Walshy•3mo ago
hmm i thought we were dumping the proper api error, i mean it'll just say "internal error" but alas, would have been nice anyway, let me get this escalated
Sir 2BD
Sir 2BD•3mo ago
Thank you so much!!! I wasn't sure if this was something I needed to make an actual support case for, or just a skill issue on my part. Lemme know if you need any more info from me to escalate
Nolan
Nolan•3mo ago
Hey there! Just letting you know I picked up the escalation from Walshy here and am waiting to hear back from the engineering team! Hey there! Are you using an account-owned-token for the authentication on this?
Sir 2BD
Sir 2BD•3mo ago
Yup!
Nolan
Nolan•3mo ago
Thank you! They want to rule out the account-owned-token being the problem, could you try a user api token as a potential workaround?
Sir 2BD
Sir 2BD•3mo ago
Absolutely! Getting a different error now. I created my account API key, added the appropriate perms, and added it to my env. I'm now seeing the error message:
{"@level":"error","@message":"Error: Invalid Attribute Value Match","@module":"terraform.ui","@timestamp":"2024-10-14T19:10:55.284085Z","diagnostic":{"severity":"error","summary":"Invalid Attribute Value Match","detail":"Attribute api_key API key must be 37 characters long and only contain characters 0-9 and a-f (all lowercased), got: ***","address":"provider[\"registry.terraform.io/cloudflare/cloudflare\"]","range":{"filename":"main.tf","start":{"line":16,"column":13,"byte":245},"end":{"line":16,"column":35,"byte":267}},"snippet":{"context":"provider \"cloudflare\"","code":" api_key = var.cloudflare_api_key","start_line":16,"highlight_start_offset":12,"highlight_end_offset":34,"values":[]}},"type":"diagnostic"}
{"@level":"error","@message":"Error: Invalid Attribute Value Match","@module":"terraform.ui","@timestamp":"2024-10-14T19:10:55.284085Z","diagnostic":{"severity":"error","summary":"Invalid Attribute Value Match","detail":"Attribute api_key API key must be 37 characters long and only contain characters 0-9 and a-f (all lowercased), got: ***","address":"provider[\"registry.terraform.io/cloudflare/cloudflare\"]","range":{"filename":"main.tf","start":{"line":16,"column":13,"byte":245},"end":{"line":16,"column":35,"byte":267}},"snippet":{"context":"provider \"cloudflare\"","code":" api_key = var.cloudflare_api_key","start_line":16,"highlight_start_offset":12,"highlight_end_offset":34,"values":[]}},"type":"diagnostic"}
As a note, the *** in that error is my CI runner hiding the key that I provided. I checked the key, and the key that Cloudflare itself gave me was 40 characters long, not 37 like the error message implies. Any ideas?
cf-scott
cf-scott•3mo ago
Hi @Sir 2BD , Nolan's headed out for the day, but I'm watching this, as I have a ticket for what may be the same issue. I'll let the team know you're facing a different error now. That might be some quirk in Terraform. For now, we're going to focus on the initial issue. Hopefully the solution to the other customer's issue will be the fix for this one.
jb
jb•3mo ago
looks like you're using an API token in the API key field.
Sir 2BD
Sir 2BD•3mo ago
Ah whoops, you're totally right, I grabbed a personal token instead of a personal key. Re-running now w/ a key, will update shortly Looks like the API key worked!!! Would it be helpful if I opened a ticket with Cloudflare somewhere to cover the 500s that happen with the account token?
cf-scott
cf-scott•3mo ago
@Sir 2BD , a ticket would be great. Please post that ticket # here, and we can continue the discussion on the ticket.
Want results from more Discord servers?
Add your server