confluentinc / terraform-provider-confluent

Terraform Provider for Confluent
Apache License 2.0
118 stars 61 forks source link

Lowering Partition Count of a Topic should force a recreation instead of failure #383

Closed AlexisDaciuk closed 2 weeks ago

AlexisDaciuk commented 1 month ago

Hi,

We are trying to lowe the Partition Count of our topics via Terraform, those topics were created with Terraform too

Terraform Version : latest (right now 1.8.3) Confluent Provider Version : 1.76.0

Example code of our topic definition

resource "confluent_kafka_topic" "NAME" {
  kafka_cluster {
    id = confluent_kafka_cluster.kafka-cluster-dev.id
  }
  topic_name       = "NAME"
  partitions_count = 2

  rest_endpoint = confluent_kafka_cluster.kafka-cluster-dev.rest_endpoint

  credentials {
    key    = confluent_api_key.trade-capture-services-dev.id
    secret = confluent_api_key.trade-capture-services-dev.secret
  }
  lifecycle {
    prevent_destroy = false
  }
}

Error

Error: 400 Bad Request: The topic NAME currently has 6 partition(s); 2 would not be an increase.

We only added the partition_count line, the code otherwise is the same one that was used to create the topic

Expected behaviour

As you can't decrease the partition count in an existing topic, Terraform should recreate the topic with the new partiton count if prevent_destroy is set to false

linouk23 commented 2 weeks ago

@AlexisDaciuk, we deployed a fix for this issue in our latest 1.77.0 release of the TF Provider 🫡.