-
Notifications
You must be signed in to change notification settings - Fork 6
docs: add Terraform common troubleshooting guide #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
walker-tx
merged 2 commits into
main
from
walker/doc-82-docs-begin-common-troubleshooting-section-in-terraform
Jul 14, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
title: "Common Troubleshooting & Recipes" | ||
description: "Learn about overcoming API design incompatibilities when generating Terraform providers with Speakeasy." | ||
--- | ||
|
||
# Common Troubleshooting & Recipes | ||
|
||
## Overview | ||
|
||
When generating Terraform providers from OpenAPI specifications, you might | ||
encounter cases where your API’s structure doesn’t naturally fit Terraform’s | ||
resource-oriented approach. These differences typically occur because APIs | ||
aren’t always designed with Terraform’s infrastructure management style in | ||
mind. | ||
|
||
Speakeasy’s generator identifies these design differences and offers extensions | ||
and customization options to address them. This enables you to produce | ||
effective Terraform providers, even when your API doesn’t initially match | ||
Terraform’s requirements, simplifying what might otherwise be challenging | ||
configuration tasks. | ||
|
||
## Fixing Common API Issues | ||
|
||
### Impedance Mismatch Errors | ||
|
||
An impedance mismatch error happens when Speakeasy's generator finds properties | ||
with different data types that need to be combined into one. This error means | ||
the data types don't match up correctly across API operations (such as between | ||
request and response data, or across different operations for the same entity), | ||
which can cause problems in the Terraform provider that's being created. | ||
|
||
#### Common example | ||
|
||
A typical impedance mismatch scenario occurs in the following situation: | ||
|
||
- A request takes UUID string for task assignment: | ||
|
||
```json request.json | ||
{ | ||
"taskId": "12345", | ||
"assignee": "user-uuid-1" | ||
} | ||
``` | ||
|
||
- The response returns a full user object for that assignee: | ||
|
||
```json response.json | ||
{ | ||
"taskId": "12345", | ||
"assignee": { | ||
"id": "user-uuid-1", | ||
"name": "Alice Johnson" | ||
} | ||
} | ||
``` | ||
|
||
When the generator attempts to merge these properties, it detects that it | ||
cannot reconcile the different data types (string vs object) and yields an | ||
impedance mismatch error. | ||
|
||
#### How to Fix the Problem | ||
|
||
Speakeasy includes built-in extensions to help fix impedance mismatch errors. | ||
You can use these solutions to adjust either the request or the response data: | ||
|
||
**Option 1: Override the property name** | ||
|
||
Use `x-speakeasy-name-override` to give the mismatched properties different | ||
names so they no longer attempt to merge: | ||
|
||
```yaml openapi.yaml | ||
TaskRequest: | ||
type: object | ||
x-speakeasy-entity: Task | ||
properties: | ||
taskId: | ||
type: string | ||
assignee: | ||
type: string | ||
x-speakeasy-name-override: assigneeId # Override the name to avoid merging | ||
``` | ||
|
||
With this approach, the additional data (stored in the `assignee` response | ||
field) will still be available to Terraform consumers. However, there may be a | ||
loss of drift detection when Terraform updates the resource’s state during the | ||
read operation. | ||
|
||
Note: `x-speakeasy-name-override` can also be used to rename the conflicting | ||
property (in this case, "assignee") in the response schema to achieve the same | ||
effect. The key is to prevent a type collision between request and response. | ||
|
||
**Option 2: Ignore the mismatched property** | ||
|
||
Use `x-speakeasy-ignore` to exclude the problematic property from generation: | ||
|
||
```yaml openapi.yaml | ||
TaskResponse: | ||
type: object | ||
x-speakeasy-entity: Task | ||
properties: | ||
taskId: | ||
type: string | ||
assignee: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
name: | ||
type: string | ||
x-speakeasy-ignore: true # Ignore this property in the response | ||
``` | ||
|
||
This approach will resolve the impedance mismatch by removing the | ||
conflicting property altogether. However, this also means that the | ||
property will no longer be tracked in Terraform state. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.