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

Completion of module variables in module block #93

Closed
pecigonzalo opened this issue Dec 21, 2018 · 10 comments
Closed

Completion of module variables in module block #93

pecigonzalo opened this issue Dec 21, 2018 · 10 comments

Comments

@pecigonzalo
Copy link

I could not find any issues or references to it, but does autocompletion work from modules? We use a lot of them, and it does not seem to work for us.

@paultyng paultyng transferred this issue from hashicorp/vscode-terraform May 12, 2020
@radeksimko
Copy link
Member

radeksimko commented May 12, 2020

Hi @pecigonzalo
I'm aware that this may be a bit too late to ask given that you filed the issue in December 2018, but do you remember what the context was?

i.e. what do you mean by "completion from modules"?

There is a few aspects of modules where completion comes to mind:

  • opening module's root in IDE and getting completion inside configuration that belongs to the module
  • completing arguments within module block (module reference)
  • completing source of module block (module reference)
    • this doesn't work and I'm unsure what would the ideal UX be here. We could probably implement this as Terraform Registry search for modules there, but we might need to also account for private module Registries which are firewalled-off and I'm not sure if we have a mechanism for discovering the existence of such registry, so we can search in it

@pecigonzalo
Copy link
Author

pecigonzalo commented May 12, 2020

Unfortunately no and I was not really good at describing it initially, ill give it a look tomorrow and try to repro. Im assuming this is becoming more active now that Hashi is adopting the VSCode Terraform extension as well, that is great news as I was about to try to implement this.

@pecigonzalo
Copy link
Author

@radeksimko I got around to remember what this was about. As we use tons of modules, we wanted to be able to autocomplete module outputs when typing them.

Lets say I have module for a vpc like

resource "aws_vpc" "default" {
  [...]
}

output "vpc_id" {
  value       = "${aws_vpc.default.id}"
  description = "The VPC ID"
}

and some code like

module "vpc" {
  [...]
}

output "id" {
  value = module.vpc.vpc_id
}

When typing module.vpc. I would like to get suggestions for the possible attributes of that module, in this example vpc_id.
Ideally when consuming the module and writing inside the module block, it would be great to also get suggestions for the attributes .

@radeksimko
Copy link
Member

@pecigonzalo Understood - that's another valid case I forgot to mention above. 👍

I think this would generally fall under #38 which will come after #36 as we need to teach the parser how to parse module outputs first.

@paultyng
Copy link
Contributor

Probably dependent upon this upstream issue: hashicorp/terraform-config-inspect#24

@paultyng paultyng changed the title Autocompletion from modules Completion of module variables in module block Jun 30, 2020
@radeksimko radeksimko added the lsp label Jul 29, 2020
@lorengordon
Copy link

lorengordon commented Oct 16, 2020

Does this request for autocompletion of module outputs also extend to attributes of those outputs? For when they are complex objects, such as entire resources? E.g.

resource aws_vpc this {
  [...]
}

output vpc {
  value       = aws_vpc.this
  description = "The VPC object"
}

@radeksimko
Copy link
Member

FYI: We have just released v0.9.0 which provides basic completion for the static attributes within module block.

Completion for variables is yet to come and outputs fall under a slightly bigger task of supporting expressions which is tracked under hashicorp/hcl-lang#2

@mwarkentin
Copy link

If it's helpful (probably depends how long the follow up takes), one of my coworkers wrote a vscode extension which adds autocomplete for module variables and outputs: https://github.com/mgtrrz/terraform-completer

@radeksimko
Copy link
Member

This was implemented as part of #551 and released in 0.20.0
Module output completion was also implemented in #593 and shipped as part of the same release.

Further improvements are planned in this area and I'd recommend reviewing the list and/or subscribing to this meta issue if you are interested: hashicorp/vscode-terraform#715

Pre-filling required (module) attributes is also tracked under hashicorp/vscode-terraform#719

@radeksimko radeksimko removed the lsp label Aug 5, 2021
@github-actions
Copy link

github-actions bot commented Sep 5, 2021

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 Sep 5, 2021
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

5 participants