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
# generated by https://github.com/hashicorp/terraform-plugin-docs
3
+
page_title: "materialize_source_reference Data Source - terraform-provider-materialize"
4
+
subcategory: ""
5
+
description: |-
6
+
The materialize_source_reference data source retrieves a list of available upstream references for a given Materialize source. These references represent potential tables that can be created based on the source, but they do not necessarily indicate references the source is already ingesting. This allows users to see all upstream data that could be materialized into tables.
7
+
---
8
+
9
+
# materialize_source_reference (Data Source)
10
+
11
+
The `materialize_source_reference` data source retrieves a list of *available* upstream references for a given Materialize source. These references represent potential tables that can be created based on the source, but they do not necessarily indicate references the source is already ingesting. This allows users to see all upstream data that could be materialized into tables.
12
+
13
+
## Example Usage
14
+
15
+
```terraform
16
+
data "materialize_source_reference" "source_references" {
17
+
source_id = materialize_source_mysql.test.id
18
+
}
19
+
20
+
output "source_references" {
21
+
value = data.materialize_source_reference.my_source_references.references
22
+
}
23
+
```
24
+
25
+
<!-- schema generated by tfplugindocs -->
26
+
## Schema
27
+
28
+
### Required
29
+
30
+
-`source_id` (String) The ID of the source to get references for
31
+
32
+
### Optional
33
+
34
+
-`region` (String) The region in which the resource is located.
35
+
36
+
### Read-Only
37
+
38
+
-`id` (String) The ID of this resource.
39
+
-`references` (List of Object) The source references (see [below for nested schema](#nestedatt--references))
Guide for migrating to the new materialize_source_table_{source_type} resources.
8
+
---
9
+
10
+
# Source versioning: migrating to `materialize_source_table_{source_type}` Resource
2
11
3
12
In previous versions of the Materialize Terraform provider, source tables were defined within the source resource itself and were considered subsources of the source rather than separate entities.
4
13
5
-
This guide will walk you through the process of migrating your existing source table definitions to the new `materialize_source_table_{source}` resource.
14
+
This guide will walk you through the process of migrating your existing source table definitions to the new `materialize_source_table_{source_type}` resource.
6
15
7
-
For each source type (e.g., MySQL, Postgres, etc.), you will need to create a new `materialize_source_table_{source}` resource for each table that was previously defined within the source resource. This ensures that the tables are preserved during the migration process. For Kafka sources, you will need to create at least one `materialize_source_table_kafka` table to hold data for the kafka topic.
16
+
For each MySQL and Postgres source, you will need to create a new `materialize_source_table_{source_type}` resource for each table that was previously defined within the source resource. This ensures that the tables are preserved during the migration process. For Kafka sources, you will need to create a `materialize_source_table_kafka` table with the same name as the kafka source to contain the data for the kafka topic.
The new approach separates source definitions and table definitions. You will now create the source without specifying the tables, and then define each table using the `materialize_source_table_{source}` resource.
66
+
The new approach separates source definitions and table definitions. You will now create the source without specifying the tables, and then define each table using the `materialize_source_table_{source_type}` resource.
58
67
59
68
## Manual Migration Process
60
69
61
-
This manual migration process requires users to create new source tables using the new `materialize_source_table_{source}` resource and then remove the old ones. We'll cover examples for both MySQL and Kafka sources.
70
+
This manual migration process requires users to create new source tables using the new `materialize_source_table_{source_type}` resource and then remove the old ones. We'll cover examples for both MySQL and Kafka sources.
Before making any changes to your existing source resources, create new `materialize_source_table_{source}` resources for each table that is currently defined within your sources.
74
+
Before making any changes to your existing source resources, create new `materialize_source_table_{source_type}` resources for each table that is currently defined within your sources.
Run `terraform plan` and `terraform apply` to create the new `materialize_source_table_{source}` resources.
121
+
Run `terraform plan` and `terraform apply` to create the new `materialize_source_table_{source_type}` resources.
113
122
114
123
### Step 3: Remove Table Blocks from Source Resources
115
124
116
-
Once the new `materialize_source_table_{source}` resources are successfully created, remove all the deprecated and table-specific attributes from your source resources.
125
+
Once the new `materialize_source_table_{source_type}` resources are successfully created, remove all the deprecated and table-specific attributes from your source resources.
In the `lifecycle` block, add the `ignore_changes` meta-argument to prevent Terraform from trying to update these attributes during subsequent applies, that way Terraform won't try to update these values based on incomplete information from the state as they will no longer be defined in the source resource itself but in the new `materialize_source_table_{source}` resources.
171
-
172
-
> Note: We will make the changes to those attributes a no-op, so the `ignore_changes` block will not be necessary.
179
+
In the `lifecycle` block, add the `ignore_changes` meta-argument to prevent Terraform from trying to update these attributes during subsequent applies, that way Terraform won't try to update these values based on incomplete information from the state as they will no longer be defined in the source resource itself but in the new `materialize_source_table_{source_type}` resources.
173
180
174
181
### Step 4: Update Terraform State
175
182
@@ -179,12 +186,18 @@ After removing the `table` blocks and the table/topic specific attributes from y
179
186
180
187
After applying the changes, verify that your tables are still correctly set up in Materialize by checking the table definitions using Materialize's SQL commands.
181
188
189
+
For a more detailed view of a specific table, you can use the `SHOW CREATE TABLE` command:
190
+
191
+
```sql
192
+
SHOW CREATE TABLE materialize.public.mysql_table1_from_source;
193
+
```
194
+
182
195
## Importing Existing Tables
183
196
184
197
To import existing tables into your Terraform state, use the following command:
-`cluster_name` (String) The cluster to maintain this source.
57
57
-`comment` (String) Comment on an object in the database.
58
58
-`database_name` (String) The identifier for the source database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
59
-
-`envelope` (Block List, Max: 1, Deprecated) How Materialize should interpret records (e.g. append-only, upsert). Deprecated: Use the new materialize_source_table_kafka resource instead. (see [below for nested schema](#nestedblock--envelope))
59
+
-`envelope` (Block List, Max: 1, Deprecated) How Materialize should interpret records (e.g. append-only, upsert). Deprecated: Use the new `materialize_source_table_kafka` resource instead. (see [below for nested schema](#nestedblock--envelope))
60
60
-`expose_progress` (Block List, Max: 1) The name of the progress collection for the source. If this is not specified, the collection will be named `<src_name>_progress`. (see [below for nested schema](#nestedblock--expose_progress))
61
61
-`format` (Block List, Max: 1) How to decode raw bytes from different formats into data structures Materialize can understand at runtime. (see [below for nested schema](#nestedblock--format))
62
-
-`include_headers` (Boolean, Deprecated) Include message headers. Deprecated: Use the new materialize_source_table_kafka resource instead.
63
-
-`include_headers_alias` (String, Deprecated) Provide an alias for the headers column. Deprecated: Use the new materialize_source_table_kafka resource instead.
64
-
-`include_key` (Boolean, Deprecated) Include a column containing the Kafka message key. Deprecated: Use the new materialize_source_table_kafka resource instead.
65
-
-`include_key_alias` (String, Deprecated) Provide an alias for the key column. Deprecated: Use the new materialize_source_table_kafka resource instead.
66
-
-`include_offset` (Boolean, Deprecated) Include an offset column containing the Kafka message offset. Deprecated: Use the new materialize_source_table_kafka resource instead.
67
-
-`include_offset_alias` (String, Deprecated) Provide an alias for the offset column. Deprecated: Use the new materialize_source_table_kafka resource instead.
68
-
-`include_partition` (Boolean, Deprecated) Include a partition column containing the Kafka message partition. Deprecated: Use the new materialize_source_table_kafka resource instead.
69
-
-`include_partition_alias` (String, Deprecated) Provide an alias for the partition column. Deprecated: Use the new materialize_source_table_kafka resource instead.
70
-
-`include_timestamp` (Boolean, Deprecated) Include a timestamp column containing the Kafka message timestamp. Deprecated: Use the new materialize_source_table_kafka resource instead.
71
-
-`include_timestamp_alias` (String, Deprecated) Provide an alias for the timestamp column. Deprecated: Use the new materialize_source_table_kafka resource instead.
62
+
-`include_headers` (Boolean, Deprecated) Include message headers. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
63
+
-`include_headers_alias` (String, Deprecated) Provide an alias for the headers column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
64
+
-`include_key` (Boolean, Deprecated) Include a column containing the Kafka message key. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
65
+
-`include_key_alias` (String, Deprecated) Provide an alias for the key column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
66
+
-`include_offset` (Boolean, Deprecated) Include an offset column containing the Kafka message offset. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
67
+
-`include_offset_alias` (String, Deprecated) Provide an alias for the offset column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
68
+
-`include_partition` (Boolean, Deprecated) Include a partition column containing the Kafka message partition. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
69
+
-`include_partition_alias` (String, Deprecated) Provide an alias for the partition column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
70
+
-`include_timestamp` (Boolean, Deprecated) Include a timestamp column containing the Kafka message timestamp. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
71
+
-`include_timestamp_alias` (String, Deprecated) Provide an alias for the timestamp column. Deprecated: Use the new `materialize_source_table_kafka` resource instead.
72
72
-`key_format` (Block List, Max: 1) Set the key format explicitly. (see [below for nested schema](#nestedblock--key_format))
73
73
-`ownership_role` (String) The owernship role of the object.
74
74
-`region` (String) The region to use for the resource connection. If not set, the default region is used.
-`comment` (String) Comment on an object in the database.
54
54
-`database_name` (String) The identifier for the source database in Materialize. Defaults to `MZ_DATABASE` environment variable if set or `materialize` if environment variable is not set.
55
55
-`expose_progress` (Block List, Max: 1) The name of the progress collection for the source. If this is not specified, the collection will be named `<src_name>_progress`. (see [below for nested schema](#nestedblock--expose_progress))
56
-
-`ignore_columns` (List of String, Deprecated) Ignore specific columns when reading data from MySQL. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_mysql resource instead.
56
+
-`ignore_columns` (List of String, Deprecated) Ignore specific columns when reading data from MySQL. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_mysql` resource instead.
57
57
-`ownership_role` (String) The owernship role of the object.
58
58
-`region` (String) The region to use for the resource connection. If not set, the default region is used.
59
59
-`schema_name` (String) The identifier for the source schema in Materialize. Defaults to `public`.
60
-
-`table` (Block Set, Deprecated) Specify the tables to be included in the source. Deprecated: Use the new materialize_source_table_mysql resource instead. (see [below for nested schema](#nestedblock--table))
61
-
-`text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain MySQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_mysql resource instead.
60
+
-`table` (Block Set, Deprecated) Specify the tables to be included in the source. Deprecated: Use the new `materialize_source_table_mysql` resource instead. (see [below for nested schema](#nestedblock--table))
61
+
-`text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain MySQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_mysql` resource instead.
-`ownership_role` (String) The owernship role of the object.
63
63
-`region` (String) The region to use for the resource connection. If not set, the default region is used.
64
64
-`schema_name` (String) The identifier for the source schema in Materialize. Defaults to `public`.
65
-
-`table` (Block Set, Deprecated) Creates subsources for specific tables in the Postgres connection. Deprecated: Use the new materialize_source_table_postgres resource instead. (see [below for nested schema](#nestedblock--table))
66
-
-`text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain PostgreSQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new materialize_source_table_postgres resource instead.
65
+
-`table` (Block Set, Deprecated) Creates subsources for specific tables in the Postgres connection. Deprecated: Use the new `materialize_source_table_postgres` resource instead. (see [below for nested schema](#nestedblock--table))
66
+
-`text_columns` (List of String, Deprecated) Decode data as text for specific columns that contain PostgreSQL types that are unsupported in Materialize. Can only be updated in place when also updating a corresponding `table` attribute. Deprecated: Use the new `materialize_source_table_postgres` resource instead.
0 commit comments