How to get brokers endpoint of Amazon MSK as an output
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Amazon Managed Streaming for Apache Kafka (MSK) is a fully managed service that makes it easy for you to build and run applications that use Apache Kafka to process streaming data. Apache Kafka is an open-source platform for building real-time streaming data pipelines and applications. When you create an MSK cluster, one of the essential pieces of information you need is the broker endpoints, which allow your application to connect to the Kafka cluster.
Understanding Broker Endpoints in Amazon MSK
A broker endpoint in Amazon MSK is a URL that your application uses to connect to the Kafka brokers within your cluster. Each broker in an MSK cluster has its own unique endpoint. For applications to produce or consume messages, they need to connect to these endpoints. MSK supports two types of endpoints:
- Zookeeper Endpoint: Used for administrative operations and is typically required only for applications that use Zookeeper directly for managing Kafka.
- Bootstrap Broker Endpoint: Used by Kafka clients to connect to the Kafka cluster. This endpoint is sufficient for most of the typical Kafka operations (producing and consuming data).
How to Retrieve Broker Endpoints
To obtain the broker endpoints of your Amazon MSK cluster, you can use either the AWS Management Console or the AWS CLI.
Using AWS Management Console
- Sign in to the AWS Management Console.
- Navigate to the MSK service.
- Select the cluster for which you want to get the broker endpoints.
- In the cluster details page, under "Connectivity and security," you'll find the endpoints listed.
Using AWS CLI
You can also use the AWS Command Line Interface (CLI) to retrieve the broker endpoints. Here's the command:
Replace <ClusterArn> with the Amazon Resource Name (ARN) of your cluster, and <Region> with the AWS region your cluster is hosted in. This command returns the bootstrap broker endpoint and, if enabled, the TLS endpoint.
Example
Suppose the ARN of your MSK cluster is arn:aws:kafka:us-east-1:123456789012:cluster/my-kafka-cluster/6bc8f9999f10. You would use the following command:
This command would return something like:
Table: Summary of Commands and Endpoints
| Action | Command | Description |
| Get Bootstrap Broker Endpoints | aws kafka get-bootstrap-brokers --cluster-arn <ClusterArn> --region <Region> | Retrieves plaintext and TLS endpoints for Kafka brokers. |
| Access Zookeeper Endpoint | On AWS Console: MSK Cluster Details > Connectivity and security CLI not applicable for Zookeeper | Used for administrative operations on Kafka. |
Conclusion
Understanding and accessing broker endpoints is crucial for integrating your application with an Amazon MSK cluster. Whether you use the AWS Management Console or the AWS CLI, getting this information is straightforward once you are familiar with the process. Ensure that your security groups and network settings allow traffic on the appropriate ports (default 9092 for plaintext and 9094 for TLS) to prevent connectivity issues.
Related reading
- How to get contents of a text file from AWS s3 using a lambda function?
- how to get data from dynamodb using rest api
- How to get dynamodb to only return certain columns
- how to get hold of the azure kubernetes cluster outbound ip address
- How to get input file name as column in AWS Athena external tables
- How to get k8s master logs on EKS?
- How to get Kubernetes cluster name from K8s API
- How to get public URL after uploading image to S3?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.