Subchapter 9.1
references/hashicorp-provider-docs.mdMarkdown5 KBView on GitHub
Source of truth for this skill:
tfplugindocs.docs/ directory with expected naming conventions.Use these template paths when the corresponding provider objects exist:
docs/index.md.tmpldocs/data-sources/<name>.md.tmpldocs/resources/<name>.md.tmpldocs/ephemeral-resources/<name>.md.tmpldocs/list-resources/<name>.md.tmpldocs/functions/<name>.md.tmpldocs/actions/<name>.md.tmpldocs/guides/<name>.md.tmplThe Registry renders action pages from docs/actions/<action>.md, and
tfplugindocs generates action documentation (including missing template
scaffolds) with Terraform v1.14.0+. Action example files follow the
convention examples/actions/<action_type>/action*.tf.
Keep example HCL in the examples/ directory and pull it into templates,
instead of inlining HCL in .tmpl files:
examples/
├── provider/provider.tf # provider block for the index page only
├── resources/<type>/resource.tf # picked up by generated templates
├── data-sources/<type>/data-source.tf
└── actions/<type>/action.tf{{ tffile "examples/resources/examplecloud_widget/resource.tf" }} —
named variants get their own files (resource-with-tags.tf), each behind
its own heading in the template.terraform, provider, or output blocks in resource, data
source, or action examples. Version constraints and provider
configuration belong on the provider index page only; outputs distract
from the object being documented. (The one exception is
examples/provider/provider.tf, which exists to show provider
configuration.)terraform fmt — generated docs render the file verbatim.HashiCorp recommends wiring generator execution through go generate:
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name <provider_name>Run from repository root:
go generate ./...Alternative direct execution:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name <provider_name>Structure modeled on the largest production example, terraform-provider-aws
(website/docs/actions/ — hand-written there because that provider predates
tfplugindocs action support; new providers should generate instead):
One page per action. H1 uses an Action: prefix — # Action: examplecloud_restart_widget —
parallel to # Resource: / # Data Source: on sibling pages.
Intro paragraph states what the action does and whether it is synchronous or asynchronous, then links to the upstream service documentation for the operation it invokes.
## Example Usage starts with ### Basic Usage and must show both
halves of using an action: the action block and the resource-side
lifecycle { action_trigger { ... } } wiring — an action example without a
trigger is not runnable:
action "examplecloud_restart_widget" "example" {
config {
widget_id = examplecloud_widget.example.id
}
}
resource "terraform_data" "trigger" {
lifecycle {
action_trigger {
events = [after_create, after_update]
actions = [action.examplecloud_restart_widget.example]
}
}
}## Argument Reference lists config arguments (either flat, or split
into required/optional groups). No attribute/output reference section —
actions produce no state, and including one misleads readers.
Callout conventions (while actions remain experimental):
~> **Note:** for the preview disclaimer, e.g. “<action> is in alpha.
Its interface and behavior may change as the feature evolves, and
breaking changes are possible.”!> **Warning:** when the action causes changes Terraform does not
reconcile (e.g. it mutates a resource whose state attributes will be
stale until the next refresh) — name the affected attribute and the
consequence.If the repo tracks release notes with go-changelog, new actions use the
release-note:new-action entry type.
v.terraform-registry-manifest.json in the repository root.tfplugindocs) source and usage: