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

Clickable links in terraform plan output #1448

Open
jpogran opened this issue May 25, 2023 · 4 comments · May be fixed by #1682
Open

Clickable links in terraform plan output #1448

jpogran opened this issue May 25, 2023 · 4 comments · May be fixed by #1682
Labels
enhancement New feature or request

Comments

@jpogran
Copy link
Contributor

jpogran commented May 25, 2023

Problem Statement

If you run any command in a VS Code terminal window that outputs text with a link in it, VS Code renders the text as a clickable link. This works for web links as well as file paths.

A terraform plan output contains output that has the names/ids of the resources, which are directly related to the definitions in the configuration files being parsed.

Expected User Experience

If you run terraform plan in a VS Code terminal window and hover over a resource definition, it should indicate that it is a clickable link. Clicking the link opens the relevant file where the declaration is defined.

This is similar to the 'Go to Definition' experience.

Proposal

We can register a new terminal link handler that implements the vscode.TerminalLinkProvider interface using the vscode.window.registerTerminalLinkProvider method that will trigger when a user hovers over a line in the terminal. After detecting a resource statement, a call to terraform-ls can return location information where the statement is defined. If nothing is found, the line is left unmodified.

image
@jpogran jpogran added the enhancement New feature or request label May 25, 2023
@radeksimko
Copy link
Member

I like the idea! 👍🏻

After detecting a resource statement, ...

Is the assumption that we'd just treat any space-separated word in the terminal output as something that could be a resource address, or is there any way to detect what process generated the output and hook only into Terraform output?


At the risk of thinking outside the box (box being the extension)... This could theoretically be a Core feature where the rendered plan/apply includes links such as file.tf:Line:Col.

Downsides?

  • We'd need buy in from the Core team
  • Core would need to detect terminals accurately enough as to not render escape characters to terminals which don't support it.

Upsides?

  • This could cover potentially any IDE (subject to terminal support as mentioned above)
  • It would help avoid false positives where we'd end up linking to resource from some random string in output from non-Terraform program just because it looks like a resource address.

@dbanck
Copy link
Member

dbanck commented May 26, 2023

@xiehan xiehan added this to the 2.27.0 (tentative) milestone Jun 2, 2023
@gregorypease280
Copy link

I love this as I am currently importing a lot of resources and going back and forth is a chore

@jawadqur
Copy link

jawadqur commented Oct 2, 2023

This would be amazing to have in core actually. Is there a way where we can connect with core team and send a feature request and/or pull request?

@jpogran jpogran linked a pull request Jan 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants