New Terraform Cloudflare Provider Version 5 Upgrade is not considered and throwing error
Extension Version
v2.34.2025012311
VS Code Version
Version: 1.98.0 (Universal) Commit: 6609ac3d66f4eade5cf376d1cb76f13985724bcb Date: 2025-03-04T21:06:18.612Z (1 wk ago) Electron: 34.2.0 ElectronBuildId: 11044223 Chromium: 132.0.6834.196 Node.js: 20.18.2 V8: 13.2.152.36-electron.0 OS: Darwin arm64 24.3.0
Operating System
macOs 15.3.1 (24D70)
Terraform Version
Terraform v1.5.7 on darwin_arm64
Steps to Reproduce
New Terraform Cloudflare Provider Version 5 Upgrade is not considered and throwing error
Error : Unexpected attribute: An attribute named "rules" is not expected hereTerraform
but, as per the latest v5 docs this is not valid
Expected Behavior
rules is now a list of objects (rules = [{ ... }]) instead of multiple block attribute (rules { ... }).
Actual Behavior
throwing error
Terraform Configuration
Project Structure
Gist
No response
Anything Else?
No response
Workarounds
No response
References
No response
Help Wanted
- [ ] I'm interested in contributing a fix myself
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue 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
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
I have same error.
terraform plan works properly but VSCode extension refers wrong version even it's defined on providers.tf
It seems VSCode extension refers v4.51.0, not 5.3.0.
providers.tf
terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = ">= 5.3.0"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 1.2"
}
# Providers
provider "cloudflare" {
api_token = var.cloudflare_token
}
My environment
$ terraform version
Terraform v1.11.4
on darwin_arm64
$ tfenv list
* 1.11.4 (set by /opt/homebrew/Cellar/tfenv/3.0.0/version)
A workaround I found:
- Open and focus the file that shows the error
- CMD+SHIFT+P – Run
HashiCorp Terraform: init current folder - Edit one character in the file and save it
In my case, the errors consistently disappeared and I could at least keep on editing. Interestingly, it keeps on working when I close and reopen the editor, so I'm not sure what is causing the hiccup.
@squidfunk it doesn't work for me, still refers to v4.51.0 😔 I'm getting the error in a module file, maybe that's the difference
@domenikk I was also getting the error in a module file in a multi-module / environment project. Maybe try to remove the .terraform folder and run terraform init again, then apply the workaround. Other than that, I'm out of ideas.
@squidfunk I managed to make it work, thank you!
Running HashiCorp Terraform: init current folder from VSCode menu was apparently timing out (silently) after 30 seconds, so I tried terraform init from the terminal and then the correct version was picked up.
Ideally, this VSCode extension should load the version based on the provider constraint even in module files, but the workaround allows me to ignore this issue for now.