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

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

Open
danieldreier opened this issue May 18, 2021 · 6 comments
Open

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

danieldreier opened this issue May 18, 2021 · 6 comments
Labels
enhancement New feature or request meta

Comments

@danieldreier
Copy link

danieldreier commented May 18, 2021

Depends on #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.

  • syntax highlighting
  • completion (for block types, labels, attribute names, value types etc.)
  • hover (for all of the above)
  • relevant diagnostics for invalid configs

Proposal

@danieldreier danieldreier added enhancement New feature or request meta labels May 18, 2021
@radeksimko radeksimko changed the title Meta issue: Terraform files other than .tf meta: Completion/hover/highlighting for Terraform files other than .tf May 19, 2021
@radeksimko radeksimko changed the title meta: Completion/hover/highlighting for Terraform files other than .tf meta: Support for Terraform files other than .tf May 19, 2021
@gruckion
Copy link

gruckion commented Nov 9, 2022

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
Copy link

freeman commented Jun 29, 2023

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

@radeksimko
Copy link
Member

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 hashicorp/terraform-ls#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
Copy link

freeman commented Jul 5, 2023

@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
Copy link
Member

@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
Copy link

flcdrg commented Mar 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request meta
Projects
None yet
Development

No branches or pull requests

5 participants