Skip to content

Terraform inconsistency with Redpanda vs confluent #7717

@mattgodbolt

Description

@mattgodbolt

Version & Environment

Redpanda version: (use rpk version): 22.2.8
OS: Ubuntu 22.04 Linux
Docker: n/a
Kubernetes: n/a
terraform: 0.13.6
mongey-kafka: 0.5.1

What went wrong?

When creating topics with mongey-kafka in terraform, there are certain required parameters that get "echoed back" as config key-value pairs, which makes them appear to need to be re-terraformed every time.

What should have happened instead?

Ideally the confluent-compatible expression should apply cleanly and remain so. Or else some kind of useful error/response. I appreciate this is a third-party tool but I think it's a result of RP "echoing" back parameters (or not) that it accepted during configuration.

How to reproduce the issue?

terraform apply with a configlike:

terraform {
  required_version = ">= 0.13"

  required_providers {
    kafka = {
      source  = "mongey/kafka"
      version = "~> 0.5.1"
    }
  }
}

provider "kafka" {
  alias = "redpanda"
  bootstrap_servers = [
    "yourserversehere"
  ]
}

resource "kafka_topic" "test" {
  provider           = kafka.redpanda
  name               = "godbolt_test"
  replication_factor = 3
  partitions         = 1
}

Note that it creates ok:

kafka_topic.test: Creating...
kafka_topic.test: Creation complete after 1s [id=godbolt_test]

Then try to terraform apply a second time (which should be a no-op):

  # kafka_topic.test will be updated in-place
  ~ resource "kafka_topic" "test" {
      ~ config             = {
          - "cleanup.policy"     = "delete" -> null
          - "partition_count"    = "1" -> null
          - "replication_factor" = "3" -> null
        }
        id                 = "godbolt_test"
        name               = "godbolt_test"
        partitions         = 1
        replication_factor = 3
    }

Note how the config block is echoing the default cleanup policy, and also replicating the partition counts and replication factors, as strings. Our workaround is to duplicate the required configuration of partisions and replications, and explicitly add the default cleanup policy:

resource "kafka_topic" "test" {
  provider           = kafka.redpanda
  name               = "godbolt_test"
  replication_factor = 3
  partitions         = 1
  config = {
    "cleanup.policy"     = "delete" # only for RP
    "partition_count"    = "1" # only for RP
    "replication_factor" = "3" # only for RP
  }
}

This workaround is not necessary when terraforming a confluent kafka broker setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/kafkakind/bugSomething isn't workingsev/mediumBugs that do not meet criteria for high or critical, but are more severe than low.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions