Skip to content

fix: link built-in provider resources to the Terraform language docs - #955

Open
somaz94 wants to merge 1 commit into
terraform-docs:masterfrom
somaz94:fix/builtin-terraform-provider-docs-url
Open

somaz94 wants to merge 1 commit into
terraform-docs:masterfrom
somaz94:fix/builtin-terraform-provider-docs-url

Conversation

@somaz94

@somaz94 somaz94 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description of your changes

terraform_data and terraform_remote_state come from Terraform's built-in provider, which isn't published on the registry. In loadResources there is no required_providers entry to read a source from, so it falls back to synthesizing hashicorp/terraform (terraform/load.go:486-491), which is the deprecated external provider, and Resource.URL() then builds a registry link out of that. The generated link doesn't resolve.

This adds a carve-out in URL() that maps the built-in provider's resources to the Terraform language docs instead. terraform is a reserved provider local name and can't be declared in required_providers, so ProviderName == "terraform" is enough to identify the built-in provider unambiguously. An unrecognized built-in type returns an empty URL, which the resource templates already fall back to rendering as a plain spec.

Fixes #757

I have:

How has this code been tested

Added three cases to TestResourceURL: a built-in resource, a built-in data source, and an unrecognized built-in type.

make checkfmt, make test and make staticcheck all pass locally. make lint reports 9 issues, but they're all pre-existing: I get the identical 9 from a clean master worktree, and none of them are in the files this PR touches.

I also rendered a fixture module containing terraform_data, terraform_remote_state and tls_private_key.

Before:

Name Type
terraform_data.bootstrap resource
tls_private_key.control resource
terraform_remote_state.network data source

After:

Name Type
terraform_data.bootstrap resource
tls_private_key.control resource
terraform_remote_state.network data source

The tls_private_key row is unchanged.

@somaz94
somaz94 marked this pull request as ready for review August 14, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

terraform_data resource is misdetected as part of the deprecated external hashicorp/terraform provider

1 participant