Skip to content
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

Snippet "tf-azurerm_public_ip" generates outdated resource block. public_ip_address_allocation has beed replaced by allocation_method #1665

Closed
Jihillestad opened this issue Mar 20, 2024 · 7 comments

Comments

@Jihillestad
Copy link

Jihillestad commented Mar 20, 2024

Language Server Version

v0.32.8

Terraform Version

Terraform v1.5.7 on darwin_amd64

Client Version

NEOVIM v0.9.5 with neovim/nvim-lspconfig

Terraform Configuration

resource "azurerm_public_ip" "MyResource" {
   name = "acceptanceTestPublicIp1"
   resource_group_name = "${azurerm_resource_group.test.name}"
   public_ip_address_allocation = "static"
   location = "West US"
}

Steps to Reproduce

  1. Typing tf-azurerm_public_ip to trigger the snippet.
  2. When the snippet is activated, the LSP shows errors regarding public_ip_address_allocation not in use and allocation_method missing.

Expected Behavior

The snippet result should be something like this if the snippet is prorperly updated.

resource "azurerm_public_ip" "example" {↴
    5name                = "example"4resource_group_name = azurerm_resource_group.example.name3location            = azurerm_resource_group.example.location2allocation_method   = "Static"1 }

Actual Behavior

This is the snippet result. public_ip_address_allocation is not supported.

resource "azurerm_public_ip" "MyResource" {
   name = "acceptanceTestPublicIp1"
   resource_group_name = "${azurerm_resource_group.test.name}"
   public_ip_address_allocation = "static"
   location = "West US"
}```

### Gist

_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](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) 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
@Jihillestad Jihillestad added the bug Something isn't working label Mar 20, 2024
@dbanck
Copy link
Member

dbanck commented Mar 26, 2024

Hi @Jihillestad,

The language server does not ship with specific provider snippets. Are you using another neovim plugin for this functionality?

@dbanck dbanck added waiting-response and removed bug Something isn't working labels Mar 26, 2024
@Jihillestad
Copy link
Author

Hi @Jihillestad,

The language server does not ship with specific provider snippets. Are you using another neovim plugin for this functionality?

Looks like it's https://github.com/rafamadriz/friendly-snippets/. The issue it out of this project, sorry about that. The issue should be closed.

@dbanck
Copy link
Member

dbanck commented Mar 26, 2024

No worries!

We also provide an experimental way to pre-populate all the required attributes for a resource: https://github.com/hashicorp/vscode-terraform/?tab=readme-ov-file#code-completion (this links to the VS Code docs, but it works with any editor)

Since this is driven by the schema of the provider, it should always be up to date. Might be an alternative to consider instead of the snippets.

@Jihillestad
Copy link
Author

Sounds good!

Does it mean that loading it with a LUA file for Lazy.nvim like vscode-terraform.lua will work?

return {
  "hashicorp/vscode-terraform",
  event = { "BufReadPre", "BufNewFile" },
  config = true,
}

config = function()
  -- How to load the experimental way to pre-populate all the required attributes for a resource?
end,

@dbanck
Copy link
Member

dbanck commented Mar 26, 2024

No, you only have to add experimentalFeatures.prefillRequiredFields to your existing language server configuration.

For me, it looks like this:

lspconfig.terraformls.setup{
  on_attach = on_attach,
  capabilities = capabilities,
  init_options = {
    experimentalFeatures = {
      prefillRequiredFields = true,
    },
  },
}

@Jihillestad
Copy link
Author

It works great. Thanks a lot!

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants