hashicorp / vscode-terraform

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

meta: Support for Terraform files other than .tf #636

Open danieldreier opened 3 years ago

danieldreier commented 3 years ago

Depends on https://github.com/hashicorp/vscode-terraform/issues/638


Problem Statement

Terraform supports a number of different files for different purposes (aside from *.tf for infrastructure configuration):

The VS Code extension currently does not provide any support for the above files.

User Impact

Any users which use any of the above files would benefit from support.

It is likely that *.tfvars would have the highest impact of all - i.e. used by more users than the other files, but there is currently no data to back it up. It would make sense to just support all of the above formats.

Expected User Experience

Users will be provided with the same experience as for *.tf files today.

Proposal

gruckion commented 1 year ago

Any updates... seems like quite an easy win and import to have. Looking at my *.tftpl JSON file in black and white isn't very nice.

freeman commented 1 year ago

It seems the extension is not supporting .tf.json files as well even though the language server seems to do so https://github.com/hashicorp/terraform-ls/issues/498

radeksimko commented 1 year ago

I think there may be differences in opinions on what "support" really means.

As you pointed out, the language server does parse JSON files to provide to provide e.g. completion of references to configuration inside those JSON files. It does not however provide any code intelligence (completion, hover etc.) inside those JSON files.

As it turns out this level of support is not ideal - @dbanck points out some downsides in https://github.com/hashicorp/terraform-ls/issues/705 - so it's clear we'll have to make some changes in this area. That said I am still not sure that providing completion/hover etc. inside JSON files is what we really should be offering as the JSON format is primarily for machines to read, not humans, so I wouldn't expect humans to be hand-editing JSON files.

TL;DR @freeman Can you clarify what "not supporting" means to you?

freeman commented 1 year ago

@radeksimko In my project I have .tf.json files containing data sources (not .tfvars.json) and I get no completion from the language server in VS Code when inside the .tf files.

I do not expect language server support in the JSON files (as in fact they are generated by scripts).

radeksimko commented 1 year ago

@freeman That sounds like a bug - we should already support such a scenario, would you mind creating a separate bug report and attaching some more details, ideally with pieces of configuration, so we can reproduce and look into it, and hopefully get it fixed? 🙏🏻

flcdrg commented 6 months ago

The current docs imply that using .tfbackend will "likely provide better editing experience". It would be great to be able to update the docs to remove the word 'likely' 😄

https://developer.hashicorp.com/terraform/language/settings/backends/configuration#file