hashicorp / vscode-terraform

HashiCorp Terraform VSCode extension
https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform
Mozilla Public License 2.0
911 stars 180 forks source link

"Unexpected attribute: An attribute named "private_endpoint_network_policies" is not expected here" #1767

Closed StuartHaire closed 4 weeks ago

StuartHaire commented 1 month ago

Extension Version

v2.30.1

VS Code Version

Version: 1.89.1 (user setup) Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:13:33.891Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.19045

Operating System

Windows 10 Business Version 22H2 19045.4412

Terraform Version

v3.105.0

Steps to Reproduce

## Subnets
resource "azurerm_subnet" "my-subnet"{
  for_each              = var.subnets
  name                  = "${each.key}"
  resource_group_name   = azurerm_resource_group.rg.name
  virtual_network_name  = azurerm_virtual_network.my-vnet.name
  address_prefixes      = ["${var.subnet_network_part}.${each.value.host_part}.0/24"]
  service_endpoints     = each.value.service_endpoints
  private_endpoint_network_policies = "Enabled"
  dynamic "delegation" {
    for_each = each.value.delegation ? toset([1]) : toset([])
    content {
      name = each.value.delegation_name
      service_delegation {
        name = each.value.delegation_service_name
        actions = each.value.delegation_service_actions
      }
    }
  }
}

Line private_endpoint_network_policies = "Enabled" reports as an unexpected attribute but terraform plans and applies without issues.

Expected Behavior

No error shown

Actual Behavior

image

Error in vscode but plan and apply works.

Terraform Configuration

No response

Project Structure

No response

Gist

No response

Anything Else?

No response

Workarounds

No response

References

No response

Help Wanted

Community Note

dbanck commented 1 month ago

Hi @StuartHaire, thanks for the report.

We bundle the latest provider schema available at the time of the language server and extension release. If new attributes, blocks or resources are introduced since then, we can't automatically reflect them (yet). The next language server release will bundle the updated schema and fix the problem. We apologize for the inconvenience.

In the meantime, when you run terraform init, we'll use the appropriate provider schema from disk.

dbanck commented 4 weeks ago

@StuartHaire We have just released a new version 2.30.2. This updates the schema to the latest version and should fix the validation error. The update should show up automatically in VS Code.


If you experience any other validation related bug, please let us know via a new issue.