MaterializeInc / terraform-provider-materialize

A Terraform provider for Materialize
https://registry.terraform.io/providers/MaterializeInc/materialize
Mozilla Public License 2.0
11 stars 8 forks source link

Changing source name silently fails #194

Closed sthm closed 1 year ago

sthm commented 1 year ago

When adapting the name of an existing source, the Terraform provider tries to update the name of the source in place. This fails silently and does not adapt the name of the source in Materialize.

  # materialize_source_kafka.kafka_text_source will be updated in-place
  ~ resource "materialize_source_kafka" "kafka_text_source" {
        id                 = "u61"
      ~ name               = "kafka_json_sorce" -> "kafka_json_source"
        # (9 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

I would have expected that the source is deleted and then recreated with the new name instead.

sthm commented 1 year ago

As per Marta's comment in Slack, the source should be indeed renamed in-place. Not sure why that is not carried out correctly.

$ terraform apply
materialize_secret.confluent_api_secret: Refreshing state... [id=u63]
materialize_secret.confluent_sr_secret: Refreshing state... [id=u62]
materialize_cluster.ingest_cluster: Refreshing state... [id=u23]
materialize_cluster.compute_cluster: Refreshing state... [id=u22]
materialize_cluster_replica.ingest_replica: Refreshing state... [id=u26]
materialize_connection_kafka.confluent_cloud: Refreshing state... [id=u64]
materialize_connection_confluent_schema_registry.confluent_schema_registry: Refreshing state... [id=u65]
materialize_source_kafka.kafka_text_source: Refreshing state... [id=u67]
materialize_cluster_replica.compute_replica: Refreshing state... [id=u25]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # materialize_source_kafka.kafka_text_source will be updated in-place
  ~ resource "materialize_source_kafka" "kafka_text_source" {
        id                 = "u67"
      ~ name               = "kafka_json_source" -> "kafka_json_source_altered"
        # (9 unchanged attributes hidden)

        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

materialize_source_kafka.kafka_text_source: Modifying... [id=u67]
materialize_source_kafka.kafka_text_source: Modifications complete after 1s [id=u67]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The name of the source should now be kafka_json_source_altered. But Materialize disagrees:

staging > show sources;
            name            |   type   | size
----------------------------+----------+------
 kafka_json_source          | kafka    | "\N"
 kafka_json_source_progress | progress | "\N"
(2 rows)

Steps to reproduce: create a source through Terraform and execute terraform apply. Change the name of the source in the template and execute terraform apply again.

dehume commented 1 year ago

Will be fixed in https://github.com/MaterializeInc/terraform-provider-materialize/pull/200

dehume commented 1 year ago

Will be part of 0.0.8