Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass --if-not-exists in resource #311

Open
finallyRaunak opened this issue Jan 24, 2023 · 2 comments
Open

How to pass --if-not-exists in resource #311

finallyRaunak opened this issue Jan 24, 2023 · 2 comments

Comments

@finallyRaunak
Copy link

Hi,

Is there any way to add --if-not-exists flag in kafka_topic resource section? Please Note there are topic which are created via CLI not using terraform.

I want to convert this CLI cmd to terraform format

kafka-topics.sh \
    --bootstrap-server myip:9094 \
    --create \
    --topic topic1 \
    --partitions 2 \
    --replication-factor 2 \
    --if-not-exists 

I have this code in my main.tf

terraform {
  required_providers {
    kafka = {
      source = "Mongey/kafka"
    }
  }
}

provider "kafka" {
  bootstrap_servers = ["myip:9094"]
  tls_enabled       = false
  skip_tls_verify   = true
  sasl_mechanism    = "plain"
}

resource "kafka_topic" "topic1" {
  name               = "topic1"
  replication_factor = 2
  partitions         = 2
}

resource "kafka_topic" "topic2" {
  name               = "topic2"
  replication_factor = 2
  partitions         = 2
}

and this is the error that I am getting

Error: kafka server: Topic with this name already exists

image

Please let me know if I am doing anything in an incorrect manner.

@OneCricketeer
Copy link

@soujiro32167
Copy link

+1 to adding this option. Importing is an option, but it means either manual steps or throwaway steps in my CI pipeline

Moreover, for a large cluster, the import is super slow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants