Skip to content

Repository files navigation

Terraform Link Docs

This extension adds provider links to resources, data blocks and module sources in your Terraform files, with support for multiple documentation registries including Terraform Registry, OpenTofu, Library.tf, and custom URL templates.

Demo

Demo

Features

  • Multi-registry docs support: registry.terraform.io, search.opentofu.org, library.tf, or custom templates.

Provider Resources

Resources and data sources are automatically linked to their documentation.

resource "aws_instance" "web" {}
data "aws_ami" "example" {}

Community Providers

The extension parses required_providers blocks to correctly link resources from community or partner providers to the Terraform Registry (e.g. Cloudflare, etc.).

terraform {
  required_providers {
    cloudflare = {
      source = "cloudflare/cloudflare"
    }
  }
}

resource "cloudflare_record" "example" {}

Modules

Below are generic examples of module sources where appropriate links are added.

module "consul" {
  source = "./consul"
}
module "consul" {
  source = "hashicorp/consul/aws"
  version = "0.1.0"
}

module "consul" {
  source = "app.terraform.io/example-corp/k8s-cluster/azurerm"
  version = "1.1.0"
}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "5.0.0"
}

# Submodules
module "" {
  source  = "terraform-aws-modules/iam/aws//modules/iam-assumable-role"
  version = "5.33.1"
}
module "consul" {
  source = "github.com/hashicorp/example"
}

module "consul" {
  source = "git@github.com:hashicorp/example.git"
}
module "eks_cluster" {
  source = "git::git@github.com:owner/repo.git//modules/eks-cluster"
}

# select a revision
module "eks_cluster" {
  source = "git::git@github.com:owner/repo.git//modules/eks-cluster?ref=v0.0.1"
}

# directly select a commit using its SHA-1 hash
module "eks_cluster" {
  source = "git::git@github.com:owner/repo.git//modules/eks-cluster?ref=51d462976d84fdea54b47d80dcabbf680badcdb8"
}

# "scp-like" address syntax
module "storage" {
  source = "git::username@example.com:repo/storage.git"
}
module "consul" {
  source = "bitbucket.org/hashicorp/terraform-consul-aws"
}

Settings

This extension contributes the following settings:

  • terraform-link-docs.enableCommunityProviders: Enable/disable parsing of required_providers to support community provider links. Default is true.
  • terraform-link-docs.documentationRegistry: Select the documentation registry to use (registry.terraform.io, search.opentofu.org, library.tf, or custom). Default is registry.terraform.io.
  • terraform-link-docs.customProviderDocURLTemplate: (For custom registry) Template URL for provider documentation links.
  • terraform-link-docs.customProviderDocURLFallbackTemplate: (For custom registry) Fallback template URL for provider documentation links when the provider namespace is unknown.
  • terraform-link-docs.customModuleDocURLTemplate: (For custom registry) Template URL for public module documentation links.
  • terraform-link-docs.customSubModuleDocURLTemplate: (For custom registry) Template URL for public submodule documentation links.

About

Add provider links to resources and data blocks as well as module sources in your Terraform files.

Topics

Resources

Stars

9 stars

Watchers

2 watching

Forks

Releases

Used by

Contributors

Languages