Provider Documentation
The Terraform Registry displays documentation for the providers it hosts. This page describes the expected format for provider documentation. Provider documentation is not supported in the private registry of HCP Terraform or Terraform Enterprise.
In order to test how documents will render in the Terraform Registry, you can use the Terraform Registry Doc Preview Tool.
Publishing
The Terraform Registry publishes providers from their Git repositories, creating a version for each Git tag that matches the Semver versioning format. Provider documentation is published automatically as part of the provider release process.
Provider documentation is always tied to a provider version. A given version always displays the documentation from that version's Git commit, and the only way to publish updated documentation is to release a new version of the provider.
Storage Limits
Each document can contain no more than 500KB of data. Documents which exceed this limit will be truncated, and a note will be displayed in the Terraform Registry.
Generating Documentation
The tfplugindocs command can be used to automatically generate documentation for your provider in the format necessary for the Terraform Registry. It will read descriptions and schema from each resource and data source in your provider and generate the relevant markdown files for you.
The terraform-provider-scaffolding-framework template repository includes example usage of the tfplugindocs
command via go generate
:
If preferred you can choose to also invoke this manually for your provider. Once run, this command produces all of the content that satisfies the expected format for the Registry. Finally you can also create the documentation manually following the format and structure below. For more information on how the generation tool works, please see the terraform-plugin-docs repository.
Format
Provider documentation should be a directory of Markdown documents in the provider repository. Each Markdown document is rendered as a separate page. The directory should include a document for the provider index, a document for each resource, data source, ephemeral resource and function, and optional documents for any guides.
Directory Structure
Location | Filename | Description |
---|---|---|
docs/ | index.md | Index page for the provider. |
docs/guides/ | <guide>.md | Additional documentation for guides. |
docs/resources/ | <resource>.md | Information for a Resource. Filename should not include a <PROVIDER NAME>_ prefix. |
docs/data-sources/ | <data_source>.md | Information on a provider data source. |
docs/functions/ | <function>.md | Information on a provider function. |
docs/ephemeral-resources/ | <ephemeral-resource>.md | Information for an Ephemeral Resource. Filename should not include a <PROVIDER NAME>_ prefix. |
Note: To support provider docs already formatted for publishing to the website, the Terraform Registry also supports docs in a website/docs/
legacy directory with file extensions of .html.markdown
or .html.md
.
Headers
We strongly suggest that provider docs include the following sections to help users understand how to use the provider. Create additional sections if they would enhance usability of the resource (for example, “Imports” or “Customizable Timeouts”).
Index Headers
Resource/Data Source/Ephemeral Resource Headers
Function Headers
YAML Frontmatter
Markdown source files may contain YAML frontmatter, which provides organizational information and display hints. Frontmatter can be omitted for resources and data sources that don't require a subcategory.
Frontmatter is not rendered in the Terraform Registry web UI.
Example
Supported Attributes
The following frontmatter attributes are supported by the Terraform Registry:
- page_title - The title of this document, which will display in the docs navigation. This is only required for documents in the
guides/
folder. - subcategory - An optional additional layer of grouping that affects the display of the docs navigation; see Subcategories below for more details. Resources and data sources should be organized into subcategories if the number of resources would be difficult to quickly scan for a user. Guides should be separated into subcategories if there are multiple guides which fit into 2 or more distinct groupings.
Callouts
If you start a paragraph with a special arrow-like sigil, it will become a colored callout box. You can't make multi-paragraph callouts. For colorblind users (and for clarity in general), callouts will automatically start with a strong-emphasized word to indicate their function.
Sigil | Text prefix | Color |
---|---|---|
-> | **Note** | blue |
~> | **Note** | yellow |
!> | **Warning** | red |
Navigation Hierarchy
Provider docs are organized by category: functions, ephemeral resources, resources, data sources, and guides. At a minimum, a provider must contain an index (docs/index.md
) and at least one function, ephemeral resource, resource, or data source.
Typical Structure
A provider named example
with a resource and data source for instance
, an ephemeral resource for auth_token
, and a function named parse_instance_id
would have these 4 files:
After publishing this provider version, its page on the Terraform Registry would display a navigation which resembles this hierarchy:
- example Provider
- Functions
- parse_instance_id
- Ephemeral Resources
- example_auth_token
- Resources
- example_instance
- Data Sources
- example_instance
Subcategories
To group these resources by a service or other dimension, add the optional subcategory
field to the YAML frontmatter of the resource, data source, and function:
This would change the navigation hierarchy to the following:
- example Provider
- Compute
- Functions
- parse_instance_id
- Ephemeral Resources
- example_auth_token
- Resources
- example_instance
- Data Sources
- example_instance
- Functions
Resources, data sources, and functions without a subcategory will be rendered before any subcategories.
The following subcategories will be rendered at the bottom of the list:
- Beta
- Deprecated
Guides
Providers can optionally include 1 or more guides. These can assist users in using the provider for certain scenarios.
The title for guides is controlled with the page_title
attribute in the YAML frontmatter:
The page_title
is used (instead of the filename) for rendering the link to this guide in the navigation:
- example Provider
- Guides
- Authenticating with Example Cloud
- Functions
- parse_instance_id
- Ephemeral Resources
- example_auth_token
- Resources
- example_instance
- Data Sources
- example_instance
Guides are always rendered before resources, data sources, functions, ephemeral resources, and any subcategories.
If a page_title
attribute is not found, the title will default to the filename without the extension.
Guides Subcategories
If a provider has many guides, you can use subcategories to group them into separate top-level sections. For example, given the following directory structure:
Assuming that these three guides have titles similar to their filenames, and the first two include subcategory: "Authentication"
in their frontmatter, the Terraform Registry would display this navigation structure:
- example Provider
- Guides
- Initial Setup
- Authentication
- Authenticating with Basic Authentication
- Authenticating with OAuth
- Functions
- parse_instance_id
- Ephemeral Resources
- example_auth_token
- Resources
- example_instance
- Data Sources
- example_instance
Guides without a subcategory are always rendered before guides with subcategories. Both are always rendered before resources, data sources, functions, and ephemeral resources.
Migrating Legacy Providers Docs
For most provider docs already published to the website, no changes are necessary to publish them to the Terraform Registry.
Important: The only exceptions are providers which organize resources, data sources, or guides into subcategories. See the Subcategories section above for more information.
If you want to publish docs on the Terraform Registry that are not available on the website, take the following steps to migrate to the newer format:
- Move the
website/docs/
folder todocs/
- Expand the folder names to match the Terraform Registry's expected format:
- Rename
docs/d/
todocs/data-sources/
- Rename
docs/r/
todocs/resources/
- No changes necessary for
docs/functions/
,docs/ephemeral-resources
, ordocs/guides
- Rename
- Change file suffixes from
.html.markdown
or.html.md
to.md
.