You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/terraform/resource-configuration.mdx
+68-8Lines changed: 68 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,28 +3,88 @@ title: "Resource Configuration"
3
3
description: "Learn how to customize a generated Terraform Provider resource, such as custom descriptions."
4
4
---
5
5
6
+
import { Table } from"@/mdx/components";
7
+
6
8
# Resource Configuration
7
9
8
-
## Resource Description
10
+
## Resource Documentation
11
+
12
+
Speakeasy automatically generates provider and resource documentation that is compliant with the [public Terraform Registry requirements](https://developer.hashicorp.com/terraform/registry/providers/docs) via the HashiCorp-maintained [`terraform-plugin-docs`](https://github.com/hashicorp/terraform-plugin-docs) tool. Speakeasy runs `terraform-plugin-docs` at the end of successful generations or manually run via `go generate ./...`.
13
+
14
+
The public Terraform Registry and `terraform-plugin-docs` tool both follow specific file layout conventions.
15
+
16
+
For resources, the following file conventions are used:
17
+
18
+
<Table
19
+
data={[
20
+
{
21
+
fileConvention: "docs/data-sources/{name}.md",
22
+
example: "docs/data-sources/order.md",
23
+
description: "Data resource documentation rendered in public Terraform Registry.",
24
+
generatedBy: "terraform-plugin-docs",
25
+
},
26
+
{
27
+
fileConvention: "docs/resources/{name}.md",
28
+
example: "docs/resources/order.md",
29
+
description: "Managed resource documentation rendered in public Terraform Registry.",
The `terraform-plugin-docs` tool also supports its own advanced use case customization, such as custom templates. Refer to the [`terraform-plugin-docs` documentation](https://github.com/hashicorp/terraform-plugin-docs) for more information about those capabilities.
60
+
61
+
### Resource Description
9
62
10
63
The `x-speakeasy-entity-description` extension allows modification of the description of a Terraform data or managed resource. This is useful when augmenting the documentation in an OpenAPI specification with documentation for specific resources. This documentation is expected to be in Markdown format. Use this extension alongside the `x-speakeasy-entity` extension.
11
64
65
+
In this example, an order managed resource will have `Manage a coffee order.` written as the description in the resource code for any consuming tools, including documentation written by `terraform-plugin-docs` into `docs/resources/order.md`:
66
+
12
67
```yaml
13
68
components:
14
69
schemas:
15
70
Order:
16
71
description: An order helps you make coffee
17
72
x-speakeasy-entity: Order
18
73
x-speakeasy-entity-description: |
19
-
The order resource allows you to declaratively construct an order for coffee.
20
-
21
-
resource "speakeasy_order" "example" {
22
-
name = "Filter Blend"
23
-
price = 11.5
24
-
}
74
+
Manage a coffee order.
25
75
```
26
76
27
-
Alternatively, a template folder can be written to customize any or all aspects of generated documentation in alignment with [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs).
77
+
### Resource Example
78
+
79
+
Example resource configuration is based on the OpenAPI Specification for API operation request and response data schemas. Speakeasy only generates example configuration for configurable properties. Example configuration values use the property `example` field when available or fallback to a generated value of the expected type following any `enum` or validation fields.
80
+
81
+
Fully customize the example resource configuration by using Speakeasy [code customization capabilities](/docs/customize/code/monkey-patching).
82
+
83
+
For example, to manually manage and update the example configuration for a managed resource:
84
+
85
+
* Edit root directory `.genignore` file with an entry for `examples/resources/{type}/resource.tf`
86
+
* Edit `examples/resources/{type}/resource.tf` as necessary
87
+
* Run `go generate ./...` or Speakeasy generation to update `docs/resources/{name}.md`
0 commit comments