create-topic
This creates a topic on an AWS MSK cluster using AWS IAM. It uses the AWS API to fetch the bootstrap brokers.
Usage example:
AWS_PROFILE=deveopment AWS_REGION=us-east-2 ./create-topic \
--topic=foo \
-cluster-arn=arn:aws:kafka:us-east-2:123456789:cluster/my-msk-cluster/c30f6adc-51f1-462c-b412-827d86901a16-1
Happy path output:
2022-07-24T10:25:22.071+1000 INFO create-topic/main.go:92 Fetching default config from AWS
2022-07-24T10:25:24.441+1000 INFO create-topic/main.go:109 Bootstrap brokers {"brokers": ["b-1.my-msk-cluster.abcd12.c3.kafka.us-east-2.amazonaws.com:9098", "b-3.my-msk-cluster.abcd12.c3.kafka.us-east-2.amazonaws.com:9098", "b-2.my-msk-cluster.abcd12.c3.kafka.us-east-2.amazonaws.com:9098"]}
2022-07-24T10:25:24.441+1000 INFO create-topic/main.go:119 SASLMechanism {"name": "AWS_MSK_IAM"}
2022-07-24T10:25:24.441+1000 INFO create-topic/main.go:121 Connecting to initial broker
2022-07-24T10:25:26.290+1000 INFO create-topic/main.go:128 Requesting controller
2022-07-24T10:25:26.485+1000 INFO create-topic/main.go:135 Controller {"address": "b-3.my-msk-cluster.abcd12.c3.kafka.us-east-2.amazonaws.com:9098"}
2022-07-24T10:25:28.266+1000 INFO create-topic/main.go:150 Creating {"topic": {"Topic":"foo","NumPartitions":1,"ReplicationFactor":1,"ReplicaAssignments":null,"ConfigEntries":null}}