intellij-hcl icon indicating copy to clipboard operation
intellij-hcl copied to clipboard

Feature request: linking to terraform documentation

Open whatisaphone opened this issue 6 years ago • 11 comments

This one is a feature request. It would be nice to be able to press shift+F1 on a resource (and maybe even data, backend, provider, etc) and have it take you to straight to the Terraform docs. This feature is called External Documentation in the keymap. It's supported pretty well for Java and Python methods.

Example:

resource "aws_instance" "my-machine" {

Putting the cursor on aws_instance and hitting shift+F1 would take you here.

Another nice-to-have would be ctrl+q, or Quick Documentation. This pops up a window right in the IDE.

I'm not sure whether Terraform has enough metadata about the resources to make this possible. Keeping a manual list of URLs would not be fun. Either way, this is on my wishlist :)

whatisaphone avatar Oct 03 '17 21:10 whatisaphone

This would be so helpful! Terraform docs are difficult to navigate and locate (especially for AWS, where I have to scroll for days to find anything), so being able to jump right to the documentation would save a lot of time

eschwartz avatar Mar 26 '18 15:03 eschwartz

VSCode has this feature:

However they don't support all providers like this plugin does. They only support the "big three" (AWS/Azure/GCloud). I did a tiny bit of research on their implementation. Here is their data source. It was generated with this script (written in Node/TypeScript).

I wonder if the links couldn't be generated with just dumb string concateneation. If you look at the URL format, it seems very standard:

https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html

Maybe just assume https://www.terraform.io/docs/providers/$provider/$type/$name.html?

whatisaphone avatar Sep 14 '18 05:09 whatisaphone

This patch seems to be very helpful https://github.com/VladRassokhin/intellij-hcl/pull/221#issuecomment-500211731 but not yet merged into https://github.com/VladRassokhin/intellij-hcl/blob/master/src/kotlin/org/intellij/plugins/hcl/terraform/config/TerraformDocumentationProvider.kt

saiya avatar Nov 13 '19 06:11 saiya

@saiya in one of recent updates I've added next feature:

'Quick Documentation' is now able to show link to terraform.io.

VladRassokhin avatar Nov 13 '19 07:11 VladRassokhin

@saiya in one of recent updates I've added next feature:

'Quick Documentation' is now able to show link to terraform.io.

@VladRassokhin I'm using version 0.7.9 and cannot seem to get quick documentation to work.

With the following in place I assume I should be able to invoke "Quick Documentation" on aws_lambda_function, but nothing happens:

resource "aws_lambda_function" foo {
}

Any idea what might be wrong?

martynassateika avatar Jun 02 '20 21:06 martynassateika

If you put caret/cursor on foo it would work 100%, on other places - may not, yet nothing could be done as foo is identifier of a element (resource) and IntelliJ shows documentation for identifiers.

Although if you reference element somewhere, e.g. output x {value=aws_lambda_function.foo<caret>}, quick documentation should work.

VladRassokhin avatar Jun 06 '20 13:06 VladRassokhin

If you put caret/cursor on foo it would work 100%

Wow, can't believe I missed that. Thanks!

martynassateika avatar Jun 06 '20 14:06 martynassateika

If you put caret/cursor on foo it would work 100%, on other places - may not, yet nothing could be done as foo is identifier of a element (resource) and IntelliJ shows documentation for identifiers.

Here for a "google_service_account" resource it does not display a quick documentation text and the link displayed when pressing ctrl+q points to https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account while the documentation is actually at https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account. Also it uses "latest" as the version, which is not correct in my case: .terraform.lock.hcl does not point to the "latest" version as of today. Version used is 0.7.10, GoLand is at version 2020.3.4.

fdcds avatar Mar 25 '21 15:03 fdcds

This stopped working for me. I am using IntelliJ IDEA 2021.3.1 and the current version of the plugin (0.7.14). Anybody else experiencing this?

Instead of opening the documentation in the browser an empty quick documentation popup opens.

carlduevel avatar Jan 09 '22 16:01 carlduevel

@carlduevel I have the same problem recently. Opened an explicit issue in https://github.com/VladRassokhin/intellij-hcl/issues/372 so that this doesn't get lost.

frosforever avatar Jan 12 '22 17:01 frosforever

I just installed version 0.7.15 and it works, BUT it appends .html to the webpage which breaks the link as the TF Registry docs don't support the .html

M1kep avatar Feb 06 '22 23:02 M1kep