Skip to content

materialize_source_postgres forces unnecessary recreate on import due to publication and postgres_connection #713

@bobbyiliev

Description

@bobbyiliev

What version of the Materialize Terraform provider are you using?

v0.8.16

What version of the Terraform CLI are you using?

v1.9.8

What version of Materialize are you using?

v0.145.2

What is the issue?

When importing a materialize_source_postgres resource, the Terraform provider generates a plan that forces the resource to be recreated, even though the imported state matches the actual configuration in Materialize.

This happens because the publication field and the postgres_connection block are imported as null, which causes Terraform to treat the values defined in configuration as changes. As a result, Terraform plans to destroy and recreate the resource unnecessarily.

This behavior could lead to problems in scenarios where resources are manually added and later imported, especially during recovery workflows. While it's not currently blocking, it could become an issue in the future.

A temporary workaround is to use the lifecycle.ignore_changes block to prevent changes to these fields from triggering recreation:

lifecycle {
  ignore_changes = [publication, postgres_connection]
}

However, this is not ideal, as it also suppresses legitimate changes to these fields.

As a follow-up, this might also affect the WIP PR here: #693

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions