-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add initial support for CREATE TABLE ... FROM WEBHOOK
- Loading branch information
1 parent
d759386
commit 910e645
Showing
11 changed files
with
1,146 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,144 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "materialize_source_table_webhook Resource - terraform-provider-materialize" | ||
subcategory: "" | ||
description: |- | ||
A webhook source table allows reading data directly from webhooks. | ||
--- | ||
|
||
# materialize_source_table_webhook (Resource) | ||
|
||
A webhook source table allows reading data directly from webhooks. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "materialize_source_table_webhook" "example_webhook" { | ||
name = "example_webhook" | ||
body_format = "json" | ||
check_expression = "headers->'x-mz-api-key' = secret" | ||
include_headers { | ||
not = ["x-mz-api-key"] | ||
} | ||
check_options { | ||
field { | ||
headers = true | ||
} | ||
} | ||
check_options { | ||
field { | ||
secret { | ||
name = materialize_secret.password.name | ||
database_name = materialize_secret.password.database_name | ||
schema_name = materialize_secret.password.schema_name | ||
} | ||
} | ||
alias = "secret" | ||
} | ||
} | ||
# CREATE TABLE example_webhook FROM WEBHOOK | ||
# BODY FORMAT json | ||
# INCLUDE HEADERS ( NOT 'x-mz-api-key' ) | ||
# CHECK ( | ||
# WITH ( HEADERS, SECRET materialize.public.password AS secret) | ||
# headers->'x-mz-api-key' = secret | ||
# ); | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `body_format` (String) The body format of the webhook. | ||
- `name` (String) The identifier for the table. | ||
|
||
### Optional | ||
|
||
- `check_expression` (String) The check expression for the webhook. | ||
- `check_options` (Block List) The check options for the webhook. (see [below for nested schema](#nestedblock--check_options)) | ||
- `comment` (String) Comment on an object in the database. | ||
- `database_name` (String) The identifier for the table database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. | ||
- `include_header` (Block List) Map a header value from a request into a column. (see [below for nested schema](#nestedblock--include_header)) | ||
- `include_headers` (Block List, Max: 1) Include headers in the webhook. (see [below for nested schema](#nestedblock--include_headers)) | ||
- `ownership_role` (String) The owernship role of the object. | ||
- `region` (String) The region to use for the resource connection. If not set, the default region is used. | ||
- `schema_name` (String) The identifier for the table schema in Materialize. Defaults to `public`. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `qualified_sql_name` (String) The fully qualified name of the table. | ||
|
||
<a id="nestedblock--check_options"></a> | ||
### Nested Schema for `check_options` | ||
|
||
Required: | ||
|
||
- `field` (Block List, Min: 1, Max: 1) The field for the check options. (see [below for nested schema](#nestedblock--check_options--field)) | ||
|
||
Optional: | ||
|
||
- `alias` (String) The alias for the check options. | ||
- `bytes` (Boolean) Change type to `bytea`. | ||
|
||
<a id="nestedblock--check_options--field"></a> | ||
### Nested Schema for `check_options.field` | ||
|
||
Optional: | ||
|
||
- `body` (Boolean) The body for the check options. | ||
- `headers` (Boolean) The headers for the check options. | ||
- `secret` (Block List, Max: 1) The secret for the check options. (see [below for nested schema](#nestedblock--check_options--field--secret)) | ||
|
||
<a id="nestedblock--check_options--field--secret"></a> | ||
### Nested Schema for `check_options.field.secret` | ||
|
||
Required: | ||
|
||
- `name` (String) The secret name. | ||
|
||
Optional: | ||
|
||
- `database_name` (String) The secret database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set. | ||
- `schema_name` (String) The secret schema name. Defaults to `public`. | ||
|
||
|
||
|
||
|
||
<a id="nestedblock--include_header"></a> | ||
### Nested Schema for `include_header` | ||
|
||
Required: | ||
|
||
- `header` (String) The name for the header. | ||
|
||
Optional: | ||
|
||
- `alias` (String) The alias for the header. | ||
- `bytes` (Boolean) Change type to `bytea`. | ||
|
||
|
||
<a id="nestedblock--include_headers"></a> | ||
### Nested Schema for `include_headers` | ||
|
||
Optional: | ||
|
||
- `all` (Boolean) Include all headers. | ||
- `not` (List of String) Headers that should be excluded. | ||
- `only` (List of String) Headers that should be included. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
# Source tables can be imported using the source table id: | ||
terraform import materialize_source_table_webhook.example_source_table_webhook <region>:<source_table_id> | ||
|
||
# Source id and information be found in the `mz_catalog.mz_tables` table | ||
# The region is the region where the database is located (e.g. aws/us-east-1) | ||
``` |
This file contains 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
5 changes: 5 additions & 0 deletions
5
examples/resources/materialize_source_table_webhook/import.sh
This file contains 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,5 @@ | ||
# Source tables can be imported using the source table id: | ||
terraform import materialize_source_table_webhook.example_source_table_webhook <region>:<source_table_id> | ||
|
||
# Source id and information be found in the `mz_catalog.mz_tables` table | ||
# The region is the region where the database is located (e.g. aws/us-east-1) |
33 changes: 33 additions & 0 deletions
33
examples/resources/materialize_source_table_webhook/resource.tf
This file contains 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,33 @@ | ||
resource "materialize_source_table_webhook" "example_webhook" { | ||
name = "example_webhook" | ||
body_format = "json" | ||
check_expression = "headers->'x-mz-api-key' = secret" | ||
include_headers { | ||
not = ["x-mz-api-key"] | ||
} | ||
|
||
check_options { | ||
field { | ||
headers = true | ||
} | ||
} | ||
|
||
check_options { | ||
field { | ||
secret { | ||
name = materialize_secret.password.name | ||
database_name = materialize_secret.password.database_name | ||
schema_name = materialize_secret.password.schema_name | ||
} | ||
} | ||
alias = "secret" | ||
} | ||
} | ||
|
||
# CREATE TABLE example_webhook FROM WEBHOOK | ||
# BODY FORMAT json | ||
# INCLUDE HEADERS ( NOT 'x-mz-api-key' ) | ||
# CHECK ( | ||
# WITH ( HEADERS, SECRET materialize.public.password AS secret) | ||
# headers->'x-mz-api-key' = secret | ||
# ); |
Oops, something went wrong.