-
Notifications
You must be signed in to change notification settings - Fork 566
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
Support for cloudflare_worker_script
resources being module syntax
#1417
Comments
My $0.02 suggestion: Instead of:
How about:
|
Currently I have a fairy hacky start of a solution where I have to use What I've learnt is that this only fails when you've outputted a |
Hello , I am currently blocked by this. I am implementing the service worker bindings like instructed in the official docs but it fails in my terraform (Unexpected token 'export'). Do we have some trick to bypass this stupid error ? I am not using wrangler |
It seems like cloudflare/cloudflare-go#794 fixed this issue, and we might be able to use it here soon? |
@dotansimha it's halfway there -- uploading a module script works but downloading it returns a raw multipart/form-data body, which would put the work onto the caller to parse in order to compare the terraform state and determine whether the resource has changed. See cloudflare/cloudflare-go#1040 for my personal first effort at a solution, but there isn't an official direction on this yet, nor on how to handle a multiscript bundle. |
cloudflare/cloudflare-go#1040 is landed! With cloudflare-go 0.49.0, it will be possible to both push a module-format worker script and also download one, enabling the terraform state refresh and comparison steps. Multiple-script workers are still an open issue that isn't fully explored, but I probably won't be pushing through solving that. |
This functionality has been released in v3.23.0 of the Terraform Cloudflare Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you! |
Current Terraform and Cloudflare provider version
Description
Similar to the proposed upstream change (cloudflare/cloudflare-go#794),
cloudflare_worker_script
resource needs to be aware of Worker module syntax. The quick tl;dr: Workers only accepts module-based workers when uploaded withContent-Type: application/javascript+module
header.It seems most worth it to add a
module
boolean parameter, and pass through through to cloudflare-go.Attempting to upload a valid worker without this sort of change results in a response:
Use cases
Uploading workers scripts based on ES Modules, documented here: https://developers.cloudflare.com/workers/learning/migrating-to-module-workers
Potential Terraform configuration
References
The text was updated successfully, but these errors were encountered: