I build a Module to Create or Edit Topics. I use Data Source Topic to get Topic; if it does not exist, run to create. If it exists, merge config from the data source with some new field of topic.config. But Data Source, when not found, Topic returns an error 404 not found, breaking all struct. We usually use a built-in function to solve this try(data.confluent_kafka_topic.main, {}) but try cannot process this kind of return of Error.
│ Error: error reading Kafka Topic "topic_1": 404 Not Found: This server does not host this topic-partition.
│
│ with data.confluent_kafka_topic.orders,
│ on main.tf line 49, in data "confluent_kafka_topic" "orders":
│ 49: data "confluent_kafka_topic" "orders" {
│
What expected:
It is expected try can change the value of Data Source to {}
Temporarily Solution:
I create a variable called isCreate and set true of false to active creation in this module or edit.
What happens:
I build a Module to Create or Edit Topics. I use Data Source Topic to get Topic; if it does not exist, run to create. If it exists, merge config from the data source with some new field of topic.config. But Data Source, when not found, Topic returns an error 404 not found, breaking all struct. We usually use a built-in function to solve this
try(data.confluent_kafka_topic.main, {})
buttry
cannot process this kind of return of Error.Output:
What expected:
It is expected try can change the value of Data Source to
{}
Temporarily Solution:
I create a variable called
isCreate
and set true of false to active creation in this module or edit.