terraform-provider-cloudflare
terraform-provider-cloudflare copied to clipboard
Pages does not update project when removing environment variables
Confirmation
- [X] My issue isn't already found on the issue tracker.
- [X] I have replicated my issue using the latest version of the provider and it is still present.
Terraform and Cloudflare provider version
Terraform v1.5.0 on windows_amd64
- provider registry.terraform.io/1password/onepassword v1.1.4
- provider registry.terraform.io/cloudflare/cloudflare v4.11.0
- provider registry.terraform.io/hashicorp/http v3.4.0
Affected resource(s)
pages_project
Terraform configuration files
resource "cloudflare_pages_project" "test-project" {
account_id = var.account_id
name = "test-project"
production_branch = "main"
deployment_configs {
preview {
always_use_latest_compatibility_date = true
fail_open = false
environment_variables = {
NODE_VERSION = "18"
}
placement {}
}
production {
fail_open = false
environment_variables = {
NODE_VERSION = "18"
PYTHON_VERSION = "3.7"
}
placement {}
}
}
}
Link to debug output
https://gist.github.com/Cyb3r-Jak3/57af688997416a9027b10f9141076b76
Panic output
No response
Expected output
That deleting the environment variable of PYTHON_VERSION removes it from the project
Actual output
The variable still set.
Steps to reproduce
- Create a pages project with an environment variable
- Delete the environment variable
- The environment variable stays
Additional factoids
It appears to be an issue with the backend API, as the PATCH request has the variable removed, but the response still has it. Looking at how the dashboard handles it, it sets the variable as a null value.
References
No response
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.
what you're seeing here is a consequence of the service using a HTTP PATCH. as HTTP schemantics for PATCH are (generally) "only modify what changes in the payload" you can't really know what to remove. that is where a PUT request is usually a better choice which gives you the entirety of the resource picture.
@WalshyDev is this something you can address in the service itself when parameters are removed from the env var payloads?
Yeah as mentioned, this is a PATCH not PUT so expected from an API perspective.
imo the service should not change here. { env_vars: { ENV: {} } } is a lot less explicit than { env_vars: { ENV: null } } for removal
I'd say that an empty env object is expected to not change (just like an empty root project does not change).