Skip to content

Commit e4eb70d

Browse files
committed
add initial support for CREATE TABLE ... FROM WEBHOOK
1 parent abf85a9 commit e4eb70d

File tree

11 files changed

+1146
-3
lines changed

11 files changed

+1146
-3
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "materialize_source_table_webhook Resource - terraform-provider-materialize"
4+
subcategory: ""
5+
description: |-
6+
A webhook source table allows reading data directly from webhooks.
7+
---
8+
9+
# materialize_source_table_webhook (Resource)
10+
11+
A webhook source table allows reading data directly from webhooks.
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "materialize_source_table_webhook" "example_webhook" {
17+
name = "example_webhook"
18+
body_format = "json"
19+
check_expression = "headers->'x-mz-api-key' = secret"
20+
include_headers {
21+
not = ["x-mz-api-key"]
22+
}
23+
24+
check_options {
25+
field {
26+
headers = true
27+
}
28+
}
29+
30+
check_options {
31+
field {
32+
secret {
33+
name = materialize_secret.password.name
34+
database_name = materialize_secret.password.database_name
35+
schema_name = materialize_secret.password.schema_name
36+
}
37+
}
38+
alias = "secret"
39+
}
40+
}
41+
42+
# CREATE TABLE example_webhook FROM WEBHOOK
43+
# BODY FORMAT json
44+
# INCLUDE HEADERS ( NOT 'x-mz-api-key' )
45+
# CHECK (
46+
# WITH ( HEADERS, SECRET materialize.public.password AS secret)
47+
# headers->'x-mz-api-key' = secret
48+
# );
49+
```
50+
51+
<!-- schema generated by tfplugindocs -->
52+
## Schema
53+
54+
### Required
55+
56+
- `body_format` (String) The body format of the webhook.
57+
- `name` (String) The identifier for the table.
58+
59+
### Optional
60+
61+
- `check_expression` (String) The check expression for the webhook.
62+
- `check_options` (Block List) The check options for the webhook. (see [below for nested schema](#nestedblock--check_options))
63+
- `comment` (String) Comment on an object in the database.
64+
- `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.
65+
- `include_header` (Block List) Map a header value from a request into a column. (see [below for nested schema](#nestedblock--include_header))
66+
- `include_headers` (Block List, Max: 1) Include headers in the webhook. (see [below for nested schema](#nestedblock--include_headers))
67+
- `ownership_role` (String) The owernship role of the object.
68+
- `region` (String) The region to use for the resource connection. If not set, the default region is used.
69+
- `schema_name` (String) The identifier for the table schema in Materialize. Defaults to `public`.
70+
71+
### Read-Only
72+
73+
- `id` (String) The ID of this resource.
74+
- `qualified_sql_name` (String) The fully qualified name of the table.
75+
76+
<a id="nestedblock--check_options"></a>
77+
### Nested Schema for `check_options`
78+
79+
Required:
80+
81+
- `field` (Block List, Min: 1, Max: 1) The field for the check options. (see [below for nested schema](#nestedblock--check_options--field))
82+
83+
Optional:
84+
85+
- `alias` (String) The alias for the check options.
86+
- `bytes` (Boolean) Change type to `bytea`.
87+
88+
<a id="nestedblock--check_options--field"></a>
89+
### Nested Schema for `check_options.field`
90+
91+
Optional:
92+
93+
- `body` (Boolean) The body for the check options.
94+
- `headers` (Boolean) The headers for the check options.
95+
- `secret` (Block List, Max: 1) The secret for the check options. (see [below for nested schema](#nestedblock--check_options--field--secret))
96+
97+
<a id="nestedblock--check_options--field--secret"></a>
98+
### Nested Schema for `check_options.field.secret`
99+
100+
Required:
101+
102+
- `name` (String) The secret name.
103+
104+
Optional:
105+
106+
- `database_name` (String) The secret database name. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
107+
- `schema_name` (String) The secret schema name. Defaults to `public`.
108+
109+
110+
111+
112+
<a id="nestedblock--include_header"></a>
113+
### Nested Schema for `include_header`
114+
115+
Required:
116+
117+
- `header` (String) The name for the header.
118+
119+
Optional:
120+
121+
- `alias` (String) The alias for the header.
122+
- `bytes` (Boolean) Change type to `bytea`.
123+
124+
125+
<a id="nestedblock--include_headers"></a>
126+
### Nested Schema for `include_headers`
127+
128+
Optional:
129+
130+
- `all` (Boolean) Include all headers.
131+
- `not` (List of String) Headers that should be excluded.
132+
- `only` (List of String) Headers that should be included.
133+
134+
## Import
135+
136+
Import is supported using the following syntax:
137+
138+
```shell
139+
# Source tables can be imported using the source table id:
140+
terraform import materialize_source_table_webhook.example_source_table_webhook <region>:<source_table_id>
141+
142+
# Source id and information be found in the `mz_catalog.mz_tables` table
143+
# The region is the region where the database is located (e.g. aws/us-east-1)
144+
```

docs/resources/source_webhook.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
page_title: "materialize_source_webhook Resource - terraform-provider-materialize"
44
subcategory: ""
55
description: |-
6-
A webhook source describes a webhook you want Materialize to read data from.
6+
A webhook source describes a webhook you want Materialize to read data from. This resource is deprecated and will be removed in a future release. Please use materialize_source_table_webhook instead.
77
---
88

99
# materialize_source_webhook (Resource)
1010

11-
A webhook source describes a webhook you want Materialize to read data from.
11+
A webhook source describes a webhook you want Materialize to read data from. This resource is deprecated and will be removed in a future release. Please use materialize_source_table_webhook instead.
1212

1313
## Example Usage
1414

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Source tables can be imported using the source table id:
2+
terraform import materialize_source_table_webhook.example_source_table_webhook <region>:<source_table_id>
3+
4+
# Source id and information be found in the `mz_catalog.mz_tables` table
5+
# The region is the region where the database is located (e.g. aws/us-east-1)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
resource "materialize_source_table_webhook" "example_webhook" {
2+
name = "example_webhook"
3+
body_format = "json"
4+
check_expression = "headers->'x-mz-api-key' = secret"
5+
include_headers {
6+
not = ["x-mz-api-key"]
7+
}
8+
9+
check_options {
10+
field {
11+
headers = true
12+
}
13+
}
14+
15+
check_options {
16+
field {
17+
secret {
18+
name = materialize_secret.password.name
19+
database_name = materialize_secret.password.database_name
20+
schema_name = materialize_secret.password.schema_name
21+
}
22+
}
23+
alias = "secret"
24+
}
25+
}
26+
27+
# CREATE TABLE example_webhook FROM WEBHOOK
28+
# BODY FORMAT json
29+
# INCLUDE HEADERS ( NOT 'x-mz-api-key' )
30+
# CHECK (
31+
# WITH ( HEADERS, SECRET materialize.public.password AS secret)
32+
# headers->'x-mz-api-key' = secret
33+
# );

0 commit comments

Comments
 (0)