Skip to content

Commit dfd6eac

Browse files
committed
Sync open source content 🐝 (from 645291dd5c2b8c37cf42d63b074ecfcc90da44a7)
1 parent 9ae7390 commit dfd6eac

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

docs/speakeasy-reference/generation/terraform-config.mdx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ terraform:
2525
name: "packageName",
2626
required: "true",
2727
default: "terraform",
28-
description: "Terraform Provider name. Prefixes all resource names. For providers published in the public Terraform Registry, this typically matches the suffix after terraform-provider- in the GitHub Repository name.",
28+
description:
29+
"Terraform Provider name. Prefixes all resource names unless `providerTypeNameOverride` is set. For providers published in the public Terraform Registry, this typically matches the suffix after terraform-provider- in the GitHub Repository name.",
2930
},
3031
{
3132
name: "author",
3233
required: "true",
3334
default: "speakeasy",
34-
description: "Terraform Provider namespace. For providers published in the public Terraform Registry, this typically matches the GitHub Organization name.",
35+
description:
36+
"Terraform Provider namespace. For providers published in the public Terraform Registry, this typically matches the GitHub Organization name.",
37+
},
38+
{
39+
name: "providerTypeNameOverride",
40+
required: "false",
41+
default: "",
42+
description:
43+
"Overrides the provider type name used for resource naming. When set, this value is used as the prefix for all resource, data source, ephemeral resource, and action type names instead of `packageName`. This is useful for variant providers that need to use the same resource names as another provider (e.g. a beta provider sharing resource names with the main provider).",
3544
},
3645
]}
3746
columns={[
@@ -80,7 +89,7 @@ terraform:
8089
required: "false",
8190
default: "[]",
8291
description:
83-
"A list of `{ importLocation?: string, importAlias?: string, datasource: string }` objects to insert into the provider ephemeral resource list.",
92+
"A list of `{ importLocation?: string, importAlias?: string, resource: string }` objects to insert into the provider ephemeral resource list.",
8493
},
8594
]}
8695
columns={[

docs/terraform/customize-terraform/provider-configuration.mdx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,34 @@ The `additionalActions` key is expected to contain a list of `{ importLocation?:
217217
The `additionalFunctions` key is expected to contain a list of `{ importLocation?: string, importAlias?: string, function: string }` objects. Each `function` is inserted into the provider-managed function list. If `importLocation` or `importAlias` is defined, Speakeasy adds them to the import list at the top of the provider file.
218218

219219
To learn more about how to write a Terraform resource, please consult the [official Terraform documentation](https://developer.hashicorp.com/terraform/plugin/framework).
220+
221+
## Override provider type name
222+
223+
<Callout title="Uncommon customization" type="info">
224+
Most providers should omit `providerTypeNameOverride` and rely on the default
225+
behavior of prefixing resource type names with `packageName`. Only use this
226+
configuration to ship a variant provider that must share resource type names
227+
with another provider.
228+
</Callout>
229+
230+
By default, Terraform resource and action type names are prefixed with the `packageName` value from `gen.yaml`. Set the `providerTypeNameOverride` configuration to replace that prefix with a different value, while retaining `packageName` for Go module naming, binary naming, and Terraform Registry publishing.
231+
232+
The common use case for this is supporting a variant provider, such as a beta provider, that intentionally shares resource type names with a related provider. It mirrors the `google` and `google-beta` provider pattern, where both providers expose the same resource type names so Terraform configurations can switch between them using the [`provider` meta-argument](https://developer.hashicorp.com/terraform/language/meta-arguments/resource-provider).
233+
234+
In this example, a beta provider published as `examplecloud-beta` exposes resources with the `examplecloud` prefix to match the stable `examplecloud` provider:
235+
236+
```yaml
237+
terraform:
238+
packageName: examplecloud-beta
239+
providerTypeNameOverride: examplecloud
240+
```
241+
242+
Without this configuration, resources would be named `examplecloud-beta_thing`. With this configuration, resources are instead named `examplecloud_thing`, matching the resource type names of the stable provider. Terraform configurations can then select the beta implementation using the `provider` meta-argument:
243+
244+
```hcl
245+
resource "examplecloud_thing" "example" {
246+
provider = examplecloud-beta
247+
248+
# ...
249+
}
250+
```

0 commit comments

Comments
 (0)