Materialize Terraform Provider
The MaterializeInc/materialize Terraform provider manages Materialize resources declaratively. It works with both Materialize Cloud (SaaS) and self-managed deployments.
This skill deliberately does not duplicate the per-resource argument reference. The provider auto-generates complete documentation for every resource and data source from its schema, and that is the source of truth. This skill tells you where that reference lives and carries only the knowledge the generated docs do not: provider setup, cross-resource patterns, import workflows, and gotchas.
Where the Authoritative Reference Lives
The generated docs are in the provider repository and on the Terraform Registry:
File naming is mechanical, so you can construct the path for any resource without a catalog:
| You need |
Read this file in the provider repo |
Resource materialize_<name> |
docs/resources/<name>.md |
Data source materialize_<name> |
docs/data-sources/materialize_<name>.md |
| Provider arguments |
docs/index.md |
| Migration guides |
docs/guides/ (e.g., materialize_source_table.md) |
For example, materialize_source_kafka is documented in docs/resources/source_kafka.md. Every generated page includes a full argument reference, attribute reference, import syntax, and usually an example.
Never guess resource arguments. Read the generated doc for the resource before writing configuration. When the provider is installed locally, terraform providers schema -json gives the exact schema as ground truth.
Provider Configuration
Materialize Cloud (SaaS)
provider "materialize" {
password = var.materialize_password # app password
default_region = "aws/us-east-1"
}
Self-Managed
provider "materialize" {
host = "materialized"
port = 6875
username = "materialize"
database = "materialize"
password = var.mz_password
# Use "require" (or stricter, e.g. "verify-full") against any TLS-enabled
# deployment. "disable" is only appropriate for a local, non-TLS instance.
sslmode = "require"
}
OIDC/SSO Authentication (Self-Managed)
provider "materialize" {
host = "materialized"
port = 6875
username = var.oidc_username
password = var.oidc_id_token
database = "materialize"
options = {
oidc_auth_enabled = "true"
}
}
All arguments have environment variable equivalents: MZ_HOST, MZ_PORT, MZ_USER, MZ_DATABASE, MZ_PASSWORD, MZ_SSLMODE, MZ_DEFAULT_REGION.
Important: Self-managed mode does not support Frontegg-dependent resources (app passwords, users, SSO, SCIM). Those only work against Materialize Cloud.
Resource Map
A category map of what exists, so you know what to look up. Names only; read the generated doc for arguments.
- Compute:
materialize_cluster (materialize_cluster_replica is deprecated, use materialize_cluster with size)
- Namespaces:
materialize_database, materialize_schema
- Connections:
materialize_connection_{kafka,postgres,mysql,sqlserver,aws,ssh_tunnel,confluent_schema_registry,aws_privatelink,iceberg_catalog}
- Sources:
materialize_source_{kafka,postgres,mysql,sqlserver,load_generator}
- Source tables (the recommended model, tables defined separately from sources):
materialize_source_table_{kafka,postgres,mysql,sqlserver,webhook}
- Sinks:
materialize_sink_{kafka,iceberg}
- Views and tables:
materialize_materialized_view, materialize_view, materialize_index, materialize_table, materialize_type
- Security:
materialize_role, materialize_secret, materialize_network_policy, materialize_grant_system_privilege
- Object grants: one resource per object type (
materialize_cluster_grant, materialize_database_grant, materialize_schema_grant, materialize_table_grant, and so on), each taking role_name, privilege, and the object reference. materialize_*_grant_default_privilege variants set privileges on future objects.
- Cloud-only (Frontegg):
materialize_user, materialize_app_password, materialize_sso_*, materialize_scim_*, materialize_region
- System configuration:
materialize_system_parameter, materialize_role_parameter
- Data sources: read-only lists of the above (clusters, sources, views, roles, etc.), plus
materialize_egress_ips, materialize_current_cluster, materialize_current_database. All support region filtering.
Cross-Resource Patterns
These conventions apply across most resources and are easy to miss reading one doc page at a time.
One worked example
Connection, source, and source table compose through nested reference blocks, and credentials come from secrets:
resource "materialize_connection_kafka" "kafka" {
name = "kafka_conn"
security_protocol = "SASL_SSL"
sasl_mechanisms = "SCRAM-SHA-256"
kafka_broker {
broker = "broker1.example.com:9092"
}
sasl_username {
text = "my_user"
}
sasl_password {
secret {
name = materialize_secret.kafka_password.name
}
}
}
resource "materialize_source_kafka" "events" {
name = "events_source"
cluster_name = materialize_cluster.analytics.name
kafka_connection {
name = materialize_connection_kafka.kafka.name
}
}
resource "materialize_source_table_kafka" "events_table" {
name = "events"
topic = "events-topic"
source {
name = materialize_source_kafka.events.name
}
format {
avro {
schema_registry_connection {
name = materialize_connection_confluent_schema_registry.sr.name
}
}
}
envelope {
upsert = true
}
}
Conventions
- Qualified names: most resources expose a read-only
qualified_sql_name (database.schema.object). Cross-resource reference blocks take name, database_name, schema_name, with the latter two defaulting to materialize and public.
- Secret or text: credential arguments accept either inline
text or a secret {} reference block, as in the example above. Prefer secrets.
- Common arguments: most resources support
database_name, schema_name, comment, ownership_role, and region; connections additionally support validate.
- Identify by name:
materialize_cluster and materialize_schema support identify_by_name = true, which uses the object name as the state ID instead of the internal Materialize ID. Useful for blue/green deployments where clusters are swapped without changing Terraform state.
- Write-only arguments (Terraform 1.11+):
materialize_role.password_wo and materialize_secret.value_wo (with their *_wo_version counterparts) never enter Terraform state. Regular sensitive values are hidden from plan output but still stored in state.
Importing Existing Resources
terraform import materialize_cluster.my_cluster <region>:<cluster_id>
# or with identify_by_name:
terraform import materialize_cluster.my_cluster <region>:name:<cluster_name>
Each generated resource doc shows the exact import format. Find object IDs in the mz_catalog system tables (mz_clusters, mz_databases, mz_schemas, mz_sources, mz_sinks, mz_views, mz_connections, mz_secrets, mz_roles).
Common Gotchas
- Cloud vs self-managed: Frontegg-dependent resources (users, SSO, SCIM, app passwords) fail against self-managed instances.
- Database without public schema:
materialize_database does not auto-create a public schema. Create one explicitly if needed.
- Source table migration: the inline
table {} block in source resources is deprecated in favor of separate materialize_source_table_* resources. See docs/guides/materialize_source_table.md in the provider repo.
- Webhook sources:
materialize_source_webhook is legacy. New webhooks should use materialize_table with webhook support, though automated migration is not yet available.
- Cluster replicas deprecated: use
materialize_cluster with size for managed clusters.
- Secrets in state: values marked sensitive are hidden from plan output but stored in state. Use the write-only (
*_wo) arguments on Terraform 1.11+ to keep them out of state entirely.
Keeping This Skill Up to Date
The per-resource reference never goes stale here because it is not duplicated here: the generated docs in the provider repo are always current for the release they ship with. The verified-against value in the frontmatter records the provider commit the curated content (patterns, gotchas, resource map) was last verified against. To refresh:
- Diff the provider repository from that commit to current
main, focusing on new or deprecated resources, docs/guides/, and CHANGELOG entries.
- Update the resource map, patterns, and gotchas here if behavior changed.
- Bump
verified-against to the new commit SHA.
1---2name: materialize-terraform-provider3description: Using the Materialize Terraform provider to manage Materialize resources declaratively. Covers clusters, sources (Kafka, Postgres, MySQL, SQL Server), sinks (Kafka, Iceberg), connections, materialized views, indexes, tables, roles, grants, secrets, network policies, and cloud-only resources (users, SSO, SCIM, app passwords). Use this skill whenever the user asks about writing Terraform for Materialize, creating or configuring Materialize resources with Terraform, importing existing Materialize objects into Terraform state, configuring the Materialize provider for Cloud or self-managed, setting up RBAC or grants via Terraform, creating connections or sources in Terraform, or troubleshooting Terraform plan/apply issues with Materialize resources. Also trigger when the user mentions materialize_cluster, materialize_source_kafka, materialize_connection_postgres, or any other materialize_* resource type.4---5
6# Materialize Terraform Provider
7
8The `MaterializeInc/materialize` Terraform provider manages Materialize resources declaratively. It works with both Materialize Cloud (SaaS) and self-managed deployments.
9
10This skill deliberately does not duplicate the per-resource argument reference. The provider auto-generates complete documentation for every resource and data source from its schema, and that is the source of truth. This skill tells you where that reference lives and carries only the knowledge the generated docs do not: provider setup, cross-resource patterns, import workflows, and gotchas.
11
12## Where the Authoritative Reference Lives
13
14The generated docs are in the provider repository and on the Terraform Registry:
15
16- Repository: `docs/` in [terraform-provider-materialize](https://github.com/MaterializeInc/terraform-provider-materialize)
17- Registry: <https://registry.terraform.io/providers/MaterializeInc/materialize/latest/docs>
18
19File naming is mechanical, so you can construct the path for any resource without a catalog:
20
21| You need | Read this file in the provider repo |
22|----------|--------------------------------------|
23| Resource `materialize_<name>` | `docs/resources/<name>.md` |
24| Data source `materialize_<name>` | `docs/data-sources/materialize_<name>.md` |
25| Provider arguments | `docs/index.md` |
26| Migration guides | `docs/guides/` (e.g., `materialize_source_table.md`) |
27
28For example, `materialize_source_kafka` is documented in `docs/resources/source_kafka.md`. Every generated page includes a full argument reference, attribute reference, import syntax, and usually an example.
29
30**Never guess resource arguments.** Read the generated doc for the resource before writing configuration. When the provider is installed locally, `terraform providers schema -json` gives the exact schema as ground truth.
31
32## Provider Configuration
33
34### Materialize Cloud (SaaS)
35
36```hcl
37provider "materialize" {
38 password = var.materialize_password # app password
39 default_region = "aws/us-east-1"
40}
41```
42
43### Self-Managed
44
45```hcl
46provider "materialize" {
47 host = "materialized"
48 port = 6875
49 username = "materialize"
50 database = "materialize"
51 password = var.mz_password
52 # Use "require" (or stricter, e.g. "verify-full") against any TLS-enabled
53 # deployment. "disable" is only appropriate for a local, non-TLS instance.
54 sslmode = "require"
55}
56```
57
58### OIDC/SSO Authentication (Self-Managed)
59
60```hcl
61provider "materialize" {
62 host = "materialized"
63 port = 6875
64 username = var.oidc_username
65 password = var.oidc_id_token
66 database = "materialize"
67 options = {
68 oidc_auth_enabled = "true"
69 }
70}
71```
72
73All arguments have environment variable equivalents: `MZ_HOST`, `MZ_PORT`, `MZ_USER`, `MZ_DATABASE`, `MZ_PASSWORD`, `MZ_SSLMODE`, `MZ_DEFAULT_REGION`.
74
75**Important:** Self-managed mode does not support Frontegg-dependent resources (app passwords, users, SSO, SCIM). Those only work against Materialize Cloud.
76
77## Resource Map
78
79A category map of what exists, so you know what to look up. Names only; read the generated doc for arguments.
80
81- **Compute**: `materialize_cluster` (`materialize_cluster_replica` is deprecated, use `materialize_cluster` with `size`)
82- **Namespaces**: `materialize_database`, `materialize_schema`
83- **Connections**: `materialize_connection_{kafka,postgres,mysql,sqlserver,aws,ssh_tunnel,confluent_schema_registry,aws_privatelink,iceberg_catalog}`
84- **Sources**: `materialize_source_{kafka,postgres,mysql,sqlserver,load_generator}`
85- **Source tables** (the recommended model, tables defined separately from sources): `materialize_source_table_{kafka,postgres,mysql,sqlserver,webhook}`
86- **Sinks**: `materialize_sink_{kafka,iceberg}`
87- **Views and tables**: `materialize_materialized_view`, `materialize_view`, `materialize_index`, `materialize_table`, `materialize_type`
88- **Security**: `materialize_role`, `materialize_secret`, `materialize_network_policy`, `materialize_grant_system_privilege`
89- **Object grants**: one resource per object type (`materialize_cluster_grant`, `materialize_database_grant`, `materialize_schema_grant`, `materialize_table_grant`, and so on), each taking `role_name`, `privilege`, and the object reference. `materialize_*_grant_default_privilege` variants set privileges on future objects.
90- **Cloud-only (Frontegg)**: `materialize_user`, `materialize_app_password`, `materialize_sso_*`, `materialize_scim_*`, `materialize_region`
91- **System configuration**: `materialize_system_parameter`, `materialize_role_parameter`
92- **Data sources**: read-only lists of the above (clusters, sources, views, roles, etc.), plus `materialize_egress_ips`, `materialize_current_cluster`, `materialize_current_database`. All support `region` filtering.
93
94## Cross-Resource Patterns
95
96These conventions apply across most resources and are easy to miss reading one doc page at a time.
97
98### One worked example
99
100Connection, source, and source table compose through nested reference blocks, and credentials come from secrets:
101
102```hcl
103resource "materialize_connection_kafka" "kafka" {
104 name = "kafka_conn"
105 security_protocol = "SASL_SSL"
106 sasl_mechanisms = "SCRAM-SHA-256"
107
108 kafka_broker {
109 broker = "broker1.example.com:9092"
110 }
111
112 sasl_username {
113 text = "my_user"
114 }
115
116 sasl_password {
117 secret {
118 name = materialize_secret.kafka_password.name
119 }
120 }
121}
122
123resource "materialize_source_kafka" "events" {
124 name = "events_source"
125 cluster_name = materialize_cluster.analytics.name
126
127 kafka_connection {
128 name = materialize_connection_kafka.kafka.name
129 }
130}
131
132resource "materialize_source_table_kafka" "events_table" {
133 name = "events"
134 topic = "events-topic"
135
136 source {
137 name = materialize_source_kafka.events.name
138 }
139
140 format {
141 avro {
142 schema_registry_connection {
143 name = materialize_connection_confluent_schema_registry.sr.name
144 }
145 }
146 }
147
148 envelope {
149 upsert = true
150 }
151}
152```
153
154### Conventions
155
156- **Qualified names**: most resources expose a read-only `qualified_sql_name` (`database.schema.object`). Cross-resource reference blocks take `name`, `database_name`, `schema_name`, with the latter two defaulting to `materialize` and `public`.
157- **Secret or text**: credential arguments accept either inline `text` or a `secret {}` reference block, as in the example above. Prefer secrets.
158- **Common arguments**: most resources support `database_name`, `schema_name`, `comment`, `ownership_role`, and `region`; connections additionally support `validate`.
159- **Identify by name**: `materialize_cluster` and `materialize_schema` support `identify_by_name = true`, which uses the object name as the state ID instead of the internal Materialize ID. Useful for blue/green deployments where clusters are swapped without changing Terraform state.
160- **Write-only arguments** (Terraform 1.11+): `materialize_role.password_wo` and `materialize_secret.value_wo` (with their `*_wo_version` counterparts) never enter Terraform state. Regular sensitive values are hidden from plan output but still stored in state.
161
162## Importing Existing Resources
163
164```bash
165terraform import materialize_cluster.my_cluster <region>:<cluster_id>
166# or with identify_by_name:
167terraform import materialize_cluster.my_cluster <region>:name:<cluster_name>
168```
169
170Each generated resource doc shows the exact import format. Find object IDs in the `mz_catalog` system tables (`mz_clusters`, `mz_databases`, `mz_schemas`, `mz_sources`, `mz_sinks`, `mz_views`, `mz_connections`, `mz_secrets`, `mz_roles`).
171
172## Common Gotchas
173
174- **Cloud vs self-managed**: Frontegg-dependent resources (users, SSO, SCIM, app passwords) fail against self-managed instances.
175- **Database without public schema**: `materialize_database` does not auto-create a `public` schema. Create one explicitly if needed.
176- **Source table migration**: the inline `table {}` block in source resources is deprecated in favor of separate `materialize_source_table_*` resources. See `docs/guides/materialize_source_table.md` in the provider repo.
177- **Webhook sources**: `materialize_source_webhook` is legacy. New webhooks should use `materialize_table` with webhook support, though automated migration is not yet available.
178- **Cluster replicas deprecated**: use `materialize_cluster` with `size` for managed clusters.
179- **Secrets in state**: values marked sensitive are hidden from plan output but stored in state. Use the write-only (`*_wo`) arguments on Terraform 1.11+ to keep them out of state entirely.
180
181## Keeping This Skill Up to Date
182
183The per-resource reference never goes stale here because it is not duplicated here: the generated docs in the provider repo are always current for the release they ship with. The `verified-against` value in the frontmatter records the provider commit the curated content (patterns, gotchas, resource map) was last verified against. To refresh:
184
1851. Diff the provider repository from that commit to current `main`, focusing on new or deprecated resources, `docs/guides/`, and CHANGELOG entries.
1862. Update the resource map, patterns, and gotchas here if behavior changed.
1873. Bump `verified-against` to the new commit SHA.