and https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/guides/version-4-upgra
13 Replies
I pushed this PR with my changes. The acceptance tests for the worker script bindings pass but my cloudflare account dosent have all the paid features so I could get every test to pass.
https://github.com/cloudflare/terraform-provider-cloudflare/pull/2960
GitHub
adding_d1_support by mephmanx · Pull Request #2960 · cloudflare/ter...
Adding initial support for D1 works script bindings. Acceptance tests related to worker scripts pass.
I created a PR for my change above but getting an error. I finally got my account set up to reproduce the error but having some trouble debugging the acceptance tests to debug. Anyone have any advice on debugging the acceptance tests for the terraform-provider-cloudflare project?
=== CONT TestAccCloudflareWorkerScript_MultiScriptEnt
resource_cloudflare_workers_script_test.go:39: Step 3/3 error: Error running apply: exit status 1
Error: error updating worker script: binding MY_DATABASE of type d1 must have an
with cloudflare_worker_script.eertxymdvb, on terraform_plugin_test.tf line 18, in resource "cloudflare_worker_script" "eertxymdvb": 18: resource "cloudflare_worker_script" "eertxymdvb" {
Error: error updating worker script: binding MY_DATABASE of type d1 must have an
id
specified (10021)
with cloudflare_worker_script.eertxymdvb, on terraform_plugin_test.tf line 18, in resource "cloudflare_worker_script" "eertxymdvb": 18: resource "cloudflare_worker_script" "eertxymdvb" {
Personally I just throw in a ton of print statements 😅 but there is a guide for using a debugger under the contributing folder
Any hints on where this is?
terraform_plugin_test.tf
Trying to find places to add log statements is kind of tough...
database_id
isn't the right field for the API payload
Jacob's comment is accurate: is database_id meant to be id here?hmmm....thats what I was just trying to find...the api payload to send to cloudflare to bind the D1 DB to a worker... The 10021 error looks like an error code from cloudflare...is that correct? If you are telling me that my request dosent match the spec...I should be able to see that pretty quickly if I find the spec. I havent yet found examples of api calls that I can make through postman to test things out.
ok, I think I found it. I had the form name parameter wrong with the cloudflare-go lib. I am now getting this error:
=== CONT TestAccCloudflareWorkerScript_MultiScriptEnt
resource_cloudflare_workers_script_test.go:39: Step 3/3 error: Error running apply: exit status 1
Error: error updating worker script: D1 bindings require module-format workers. (10021)
with cloudflare_worker_script.gbgrtshapm, on terraform_plugin_test.tf line 18, in resource "cloudflare_worker_script" "gbgrtshapm": 18: resource "cloudflare_worker_script" "gbgrtshapm" { Which I imagine should be ok as the format of the test worker might be off.
Error: error updating worker script: D1 bindings require module-format workers. (10021)
with cloudflare_worker_script.gbgrtshapm, on terraform_plugin_test.tf line 18, in resource "cloudflare_worker_script" "gbgrtshapm": 18: resource "cloudflare_worker_script" "gbgrtshapm" { Which I imagine should be ok as the format of the test worker might be off.
created this PR to update the form parameter name:
https://github.com/cloudflare/cloudflare-go/pull/1450
After this change, the provider lib should work.
GitHub
updating binding form id by mephmanx · Pull Request #1450 · cloudfl...
Changing name of form binding parameter
Description
Was using wrong form parameter name for D1 binding id
Has your change been tested?
Change tested with changes to terraform-cloudflare-provider
Sc...
ignore that, it's a temp file the test runner creates. you want the lines above it
resource_cloudflare_workers_script_test.go:39: Step 3/3 error: Error running apply: exit status 1
to track down what is running.
let me shim this in and test it out
just had a look at the test and the error message is correct, you're not using a module based worker for this assertion.shuold I try to update the test to use a module based worker or is it good as it is?
it's not good as is; the tests are failing. we'll need to do a bit of juggling to get this to work as the D1 database needs to exist.
we're probably going to bump into the cyclic package import issues like i did with r2..again
i really need to find a way to initialise both versions of the provider plugins and have them play nicely together
i also really need to break every resource into a dedicated package to offset ^^
ok, is there something I can help with?