Skip to content

Commit 19e66d5

Browse files
Add TF 1.14 documentation for registry and fix up some other provider-related docs (#853)
* add action documentation and fix up some other docs * add list * Apply suggestions from code review Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com> --------- Co-authored-by: trujillo-adam <47586768+trujillo-adam@users.noreply.github.com>
1 parent 1d978f9 commit 19e66d5

File tree

8 files changed

+69
-99
lines changed

8 files changed

+69
-99
lines changed

content/terraform-docs-common/docs/plugin/best-practices/sensitive-state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ couple of recommended approaches for managing sensitive state in Terraform.
1616

1717
<Highlight>
1818

19-
Ephemeral resource support is only available in the [Terraform Plugin Framework](/terraform/plugin/framework)
19+
Ephemeral resource support is only available in the [Terraform Plugin Framework](/terraform/plugin/framework)
2020

2121
</Highlight>
2222

content/terraform-docs-common/docs/plugin/framework-benefits.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,11 @@ Additional new and improved features in the framework include:
254254
- **Data Access**: The framework makes it easier to access Terraform data (configuration, plan, and state) and value states (null, known, unknown).
255255
- **Unrestricted Type System**: The framework lets you create custom attribute types and nested attributes for resources and data sources. The framework type system does not have any restrictions for using complex types as the value for a map type.
256256
- **Validation Capabilities**: The framework exposes many more configuration validation integration points than the SDK. It is also extensible with provider-defined types that implement validation in the type itself.
257-
- **Functions**: The framework supports provider-defined functions which are exposed for practitioner configurations.
258257
- **Enhanced Import and Planning Capabilities**: The framework enables additional import and plan handling capabilities not available in SDKv2.
258+
- **Dynamic attributes**: The framework supports dynamic data types in schemas, which allows the type of an attribute to be determined at runtime.
259+
- **Functions**: The framework supports provider-defined functions which are exposed for practitioner configurations.
259260
- **Ephemeral Resources**: The framework supports ephemeral resources which do not store data in the Terraform plan or state artifacts.
261+
- **Actions**: The framework supports actions, which are additional operations for expressing workflows that don't strictly fit into CRUD resource management, such as disaster recovery or ad-hoc maintenance.
262+
- **List Resources**: The framework supports the list operation for a resource, which can be used with Terraform to discover unmanaged resources.
260263

261264
Refer to [Framework Feature Comparison](/terraform/plugin/framework/migrating/benefits) for a continued list of features, details, and examples.

content/terraform-docs-common/docs/plugin/terraform-plugin-protocol.mdx

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ During [discovery](/terraform/plugin/how-terraform-works#discovery), the Terrafo
1313

1414
Major versions of the protocol delineate Terraform CLI and Terraform Plugin compatibility. Minor versions of the protocol are additive. The protocol is implemented in [Protocol Buffers](https://developers.google.com/protocol-buffers) and [gRPC](https://grpc.io/), with the canonical source for protocol definitions located in the [Terraform CLI repository](https://github.com/hashicorp/terraform/tree/main/docs/plugin-protocol).
1515

16+
For more detail about how the protocol RPCs are used, refer to the following topics:
17+
- [Framework documentation about RPCs](/terraform/plugin/framework/internals/rpcs)
18+
- [Terraform Resource Instance Change Lifecycle documentation](https://github.com/hashicorp/terraform/blob/main/docs/resource-instance-change-lifecycle.md)
19+
1620
## Protocol Version 6
1721

1822
Protocol version 6 is compatible with Terraform CLI version 1.0 and later. Protocol version 6 includes all version 5 functionality for providers, plus:
@@ -28,6 +32,8 @@ Implementations include:
2832
* [tf5to6server](/terraform/plugin/mux/translating-protocol-version-5-to-6): A package to translate protocol version 5 providers into protocol version 6.
2933
* [tf6muxserver](/terraform/plugin/mux/combining-protocol-version-6-providers): A package to combine multiple protocol version 6 providers.
3034

35+
Refer to [Terraform Plugin RPC protocol version 6.10](https://github.com/hashicorp/terraform/blob/main/docs/plugin-protocol/tfplugin6.proto) in the Terraform repository for the protocol v6 definition.
36+
3137
## Protocol Version 5
3238

3339
Protocol version 5 is compatible with Terraform CLI version 0.12 and later.
@@ -40,85 +46,4 @@ Implementations include:
4046
* [tf6to5server](/terraform/plugin/mux/translating-protocol-version-6-to-5): A package to translate protocol version 6 providers into protocol version 5.
4147
* [tf5muxserver](/terraform/plugin/mux/combining-protocol-version-5-providers): A package to combine multiple protocol version 5 providers.
4248

43-
## Protocol RPCs
44-
45-
The Terraform plugin protocol specifies the following RPCs:
46-
47-
| Protocol Version 5 | Protocol Version 6 | Description |
48-
|------------------------------|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
49-
| `GetSchema` | `GetProviderSchema` | Returns provider schema, provider metaschema, all resource schemas and all data source schemas. |
50-
| `GetMetadata` | `GetMetadata` | Returns data source, managed resource, and function metadata, such as names. |
51-
| `GetFunctions` | `GetFunctions` | Returns function definitions. |
52-
| `CallFunction` | `CallFunction` | Called when a practitioner configuration contains a provider-defined function. |
53-
| `PrepareProviderConfig` | `ValidateProviderConfig` | Validates the practitioner supplied provider configuration by verifying types conform to the schema and supports value validation diagnostics. |
54-
| `ValidateResourceTypeConfig` | `ValidateResourceConfig` | Validates the practitioner supplied resource configuration by verifying types conform to the schema and supports value validation diagnostics. |
55-
| `ValidateDataSourceConfig` | `ValidateDataResourceConfig` | Validates the practitioner supplied data source configuration by verifying types conform to the schema and supports value validation diagnostics. |
56-
| `UpgradeResourceState` | `UpgradeResourceState` | Called when a resource has existing state. Primarily useful for when the schema version does not match the current version. The provider is expected to modify the state to upgrade it to the latest schema. |
57-
| `Configure` | `ConfigureProvider` | Passes the practitioner supplied provider configuration to the provider. |
58-
| `ReadResource` | `ReadResource` | Called when refreshing a resource's state. |
59-
| `ReadDataSource` | `ReadDataSource` | Called when refreshing a data source's state. |
60-
| `PlanResourceChange` | `PlanResourceChange` | Calculates a plan for a resource. A proposed new state is generated, which the provider can modify. |
61-
| `ApplyResourceChange` | `ApplyResourceChange` | Called when a practitioner has approved a planned change. The provider is to apply the changes contained in the plan, and return a resulting state matching the given plan. |
62-
| `ImportResourceState` | `ImportResourceState` | Called when importing a resource into state so that the resource becomes managed. |
63-
64-
![diagram: Terraform Plugin Protocol 6 RPCs](/img/docs/terraform-plugin-protocol-6-rpcs-all.png)
65-
66-
## RPCs and Terraform commands
67-
68-
The following illustrate the RPCs that are sent during execution of the specified Terraform commands.
69-
70-
The RPCs issued are for a provider that is using version 6 of the Terraform plugin protocol when the Terraform configuration contains configuration for the provider, a resource and a data source.
71-
72-
### _terraform validate_
73-
74-
Executing _terraform validate_ results in the following unique RPCs:
75-
76-
![diagram: Terraform Plugin Protocol 6 Validate RPCs](/img/docs/terraform-plugin-protocol-6-rpcs-validate.png)
77-
78-
The general sequence of RPCs is as follows:
79-
80-
- GetProviderSchema
81-
- CallFunction
82-
- ValidateProviderConfig
83-
- ValidateResourceConfig
84-
- ValidateDataResourceConfig
85-
86-
### _terraform plan_
87-
88-
Executing _terraform plan_ results in the following unique RPCs:
89-
90-
![diagram: Terraform Plugin Protocol 6 Plan RPCs](/img/docs/terraform-plugin-protocol-6-rpcs-plan.png)
91-
92-
The general sequence of RPCs is as follows:
93-
94-
- GetProviderSchema
95-
- CallFunction
96-
- ValidateProviderConfig
97-
- ValidateResourceConfig
98-
- ValidateDataResourceConfig
99-
- ConfigureProvider
100-
- ReadDataSource
101-
- PlanResourceChange
102-
103-
### _terraform apply_
104-
105-
Executing _terraform apply_ (with default -refresh=true and -auto-approve) results in the following unique RPCs:
106-
107-
![diagram: Terraform Plugin Protocol 6 Plan RPCs](/img/docs/terraform-plugin-protocol-6-rpcs-apply.png)
108-
109-
The general sequence of RPCs is as follows:
110-
111-
- GetProviderSchema
112-
- CallFunction
113-
- ValidateProviderConfig
114-
- ValidateResourceConfig
115-
- ValidateDataResourceConfig
116-
- ConfigureProvider
117-
- UpgradeResourceState
118-
- only called if resource already exists in state
119-
- ReadResource
120-
- only called if resource already exists in state
121-
- ReadDataSource
122-
- PlanResourceChange
123-
- ApplyResourceChange
124-
49+
Refer to [Terraform Plugin RPC protocol version 5.10](https://github.com/hashicorp/terraform/blob/main/docs/plugin-protocol/tfplugin5.proto) in the Terraform repository for the protocol v5 definition.

content/terraform-docs-common/docs/registry/providers/docs.mdx

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ If preferred you can choose to also invoke this manually for your provider. Once
3434

3535
## Format
3636

37-
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.
37+
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, action, list resource, function, and optional documents for any guides.
3838

3939
### Directory Structure
4040

41-
| Location | Filename | Description |
42-
| -------------------- | ------------------ | ------------------------------------------------------------------------------------ |
43-
| `docs/` | `index.md` | Index page for the provider. |
44-
| `docs/guides/` | `<guide>.md` | Additional documentation for guides. |
45-
| `docs/resources/` | `<resource>.md` | Information for a Resource. Filename should not include a `<PROVIDER NAME>_` prefix. |
46-
| `docs/data-sources/` | `<data_source>.md` | Information on a provider data source. |
47-
| `docs/functions/` | `<function>.md` | Information on a provider function. |
48-
| `docs/ephemeral-resources/` | `<ephemeral-resource>.md` | Information for an Ephemeral Resource. Filename should not include a `<PROVIDER NAME>_` prefix. |
41+
| Location | Filename | Description |
42+
|-----------------------------|---------------------------|-------------------------------------------------------------------------------------------------|
43+
| `docs/` | `index.md` | Index page for the provider. |
44+
| `docs/guides/` | `<guide>.md` | Additional documentation for guides. |
45+
| `docs/resources/` | `<resource>.md` | Information for a Resource. Filename should not include a `<PROVIDER NAME>_` prefix. |
46+
| `docs/data-sources/` | `<data_source>.md` | Information on a provider data source. |
47+
| `docs/functions/` | `<function>.md` | Information on a provider function. |
48+
| `docs/ephemeral-resources/` | `<ephemeral-resource>.md` | Information for an Ephemeral Resource. Filename should not include a `<PROVIDER NAME>_` prefix. |
49+
| `docs/actions/` | `<action>.md` | Information for an action. Filename should not include a `<PROVIDER NAME>_` prefix. |
50+
| `docs/list-resources/` | `<list-resource>.md` | Information for a list resource. Filename should not include a `<PROVIDER NAME>_` prefix. |
4951

5052
-> **Note:** To support provider docs already formatted for publishing to [the website][terraform-io-providers], the Terraform Registry also supports docs in a `website/docs/` legacy directory with file extensions of `.html.markdown` or `.html.md`.
5153

@@ -72,10 +74,12 @@ app/service documentation.
7274
* List any arguments for the provider block.
7375
````
7476

75-
#### Resource/Data Source/Ephemeral Resource Headers
77+
#### Resource Type Headers
78+
79+
Resource types include managed, data source, ephemeral, and others.
7680

7781
````
78-
# <resource name> Resource/Data Source/Ephemeral Resource
82+
# <resource name> <Resource Type>
7983
8084
Description of what this resource does, with links to official
8185
app/service documentation.
@@ -155,32 +159,50 @@ If you start a paragraph with a special arrow-like sigil, it will become a color
155159

156160
## Navigation Hierarchy
157161

158-
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.
162+
Provider docs are organized by the following categories:
163+
164+
- functions
165+
- actions
166+
- list resources
167+
- ephemeral resources
168+
- resources
169+
- data sources
170+
- guides
171+
172+
At a minimum, a provider must contain an index file, `docs/index.md`, and at least one function, action, ephemeral resource, list resource, resource, or data source.
159173

160174
### Typical Structure
161175

162-
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:
176+
A provider named `example` with a resource, list resource, and data source for `instance`, an ephemeral resource for `auth_token`, an action named `stop_instance`, and a function named `parse_instance_id` would have these 5 files:
163177

164178
```
165179
docs/
166180
index.md
181+
actions/
182+
stop_instance.md
167183
data-sources/
168184
instance.md
169185
ephemeral-resources/
170186
auth_token.md
171187
functions/
172188
parse_instance_id.md
189+
list-resources/
190+
instance.md
173191
resources/
174192
instance.md
175193
```
176194

177195
After publishing this provider version, its page on the Terraform Registry would display a navigation which resembles this hierarchy:
178196

179197
* example Provider
198+
* Actions
199+
* example_stop_instance
180200
* Functions
181201
* parse_instance_id
182202
* Ephemeral Resources
183203
* example_auth_token
204+
* List Resources
205+
* example_instance
184206
* Resources
185207
* example_instance
186208
* Data Sources
@@ -200,10 +222,14 @@ This would change the navigation hierarchy to the following:
200222

201223
* example Provider
202224
* Compute
225+
* Actions
226+
* example_stop_instance
203227
* Functions
204228
* parse_instance_id
205229
* Ephemeral Resources
206230
* example_auth_token
231+
* List Resources
232+
* example_instance
207233
* Resources
208234
* example_instance
209235
* Data Sources
@@ -225,12 +251,16 @@ docs/
225251
index.md
226252
guides/
227253
authenticating.md
254+
actions/
255+
stop_instance.md
228256
data-sources/
229257
instance.md
230258
ephemeral-resources/
231259
auth_token.md
232260
functions/
233261
parse_instance_id.md
262+
list-resources/
263+
instance.md
234264
resources/
235265
instance.md
236266
```
@@ -248,16 +278,20 @@ The `page_title` is used (instead of the filename) for rendering the link to thi
248278
* example Provider
249279
* Guides
250280
* Authenticating with Example Cloud
281+
* Actions
282+
* example_stop_instance
251283
* Functions
252284
* parse_instance_id
253285
* Ephemeral Resources
254286
* example_auth_token
287+
* List Resources
288+
* example_instance
255289
* Resources
256290
* example_instance
257291
* Data Sources
258292
* example_instance
259293

260-
Guides are always rendered before resources, data sources, functions, ephemeral resources, and any subcategories.
294+
Guides are always rendered before resources, data sources, functions, actions, ephemeral resources, list resources, and any subcategories.
261295

262296
If a `page_title` attribute is not found, the title will default to the filename without the extension.
263297

@@ -272,12 +306,16 @@ docs/
272306
authenticating-basic.md
273307
authenticating-oauth.md
274308
setup.md
309+
actions/
310+
stop_instance.md
275311
data-sources/
276312
instance.md
277313
ephemeral-resources/
278314
auth_token.md
279315
functions/
280316
parse_instance_id.md
317+
list-resources/
318+
instance.md
281319
resources/
282320
instance.md
283321
```
@@ -290,10 +328,14 @@ Assuming that these three guides have titles similar to their filenames, and the
290328
* Authentication
291329
* Authenticating with Basic Authentication
292330
* Authenticating with OAuth
331+
* Actions
332+
* example_stop_instance
293333
* Functions
294334
* parse_instance_id
295335
* Ephemeral Resources
296336
* example_auth_token
337+
* List Resources
338+
* example_instance
297339
* Resources
298340
* example_instance
299341
* Data Sources
@@ -313,7 +355,7 @@ If you want to publish docs on the Terraform Registry that are not available on
313355
1. Expand the folder names to match the Terraform Registry's expected format:
314356
* Rename `docs/d/` to `docs/data-sources/`
315357
* Rename `docs/r/` to `docs/resources/`
316-
* No changes necessary for `docs/functions/`, `docs/ephemeral-resources`, or `docs/guides`
358+
* No changes necessary for `docs/functions/`, `docs/ephemeral-resources`, `docs/list-resources`, `docs/actions`, or `docs/guides`
317359
1. Change file suffixes from `.html.markdown` or `.html.md` to `.md`.
318360

319361
[terraform-registry]: https://registry.terraform.io
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)