Search code examples
amazon-web-servicesapache-kafkaamazon-ecs

How to create topic in Kafka that running like task in AWS ECS?


How to create a topic in Kafka that runs like a task in the AWS ECS cluster? I think about AWS CLI, but I don't know what URL I need to use.


Solution

  • You can use an AdminClient interface (if you have admin creds). For example you can use python confluent_kafka package or any other lib.

    from confluent_kafka.admin import AdminClient, NewTopic
    
    
    admin_client = AdminClient({
        "bootstrap.servers": "cluster_in_ecs:9092"
    })
    
    topic_list = []
    topic_list.append(NewTopic("new_topic", 3, 2))
    admin_client.create_topics(topic_list)