10

Our AWS MSK cluster is not automatically creating topics when a producer first publishes a message to the topic. This is surprising because the default behaviour according to https://kafka.apache.org/documentation/#brokerconfigs should have auto.create.topics.enable = true.

I have attempted to set this configuration on my brokers but I am unable because the config is read-only for dynamic updates.

$ kafka-configs --bootstrap-server $KAFKA_BROKER --entity-type brokers --entity-default --alter --add-config auto.create.topics.enable=true

Error while executing config command with args '--bootstrap-server $KAFKA_BROKER --entity-type brokers --entity-default --alter --add-config auto.create.topics.enable=true'
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.InvalidRequestException: Invalid config value for resource ConfigResource(type=BROKER, name=''): Cannot update these configs dynamically: Set(auto.create.topics.enable)

note: I replaced our broker's IP with $KAFKA_BROKER in the output

How can I configure my AWS MSK Kafka cluster to enable auto creation of topics?

Alexandre Dupriez
  • 3,026
  • 20
  • 25
rpassza
  • 226
  • 1
  • 2
  • 8

2 Answers2

8

Update

You can now customise MSK configuration:

auto.create.topics.enable: Enables topic autocreation on the server.

Therefore, auto.create.topics.enable=true (defaults to false) should now do the trick as usual.


Although auto.create.topics.enable normally defaults to true, this is not the case for AWS MSK. According to these slides presented in Berlin's AWS Kafka Summit this February, the following are the default configuration parameters for Amazon MSK:

offsets.topic.replication.factor 3
transaction.state.log.replication.factor 3
transaction.state.log.min.isr 2
auto.create.topics.enable False
default.replication.factor 3
min.insync.replicas 2
unclean.leader.election.enable True
auto.leader.rebalance.enable True
authorizer.class.name kafka.security.auth.SimpleAclAuthorizer
group.initial.rebalance.delay.ms 3000
log.retention.hours 168 

Note that even Kafka docs mention that the suggested production configuration should be set to false.

SomeGuyOnAComputer
  • 5,414
  • 6
  • 40
  • 72
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
  • Please consider removing the older incorrect information from your answer. I see no reason to keep it. – Gray Jan 14 '21 at 17:09
2

Moving forward you can now set this parameter to true by customizing the configuration, however it will stay false by default since that is the recommended production configuration.

Eno Thereska
  • 234
  • 2
  • 6