To retrieve the list of bootstrap servers for a pre-existing cluster using AWS CDK MSK, you can use the AWS SDK and the describeCluster()
method to obtain the cluster configuration. Then, you can access the bootstrapBrokers
property to retrieve the list of bootstrap servers.
Here's an example TypeScript code snippet that shows how to obtain the bootstrap server in CDK:
import * as cdk from 'aws-cdk-lib';
import * as msk from 'aws-cdk-lib/aws-msk';
const app = new cdk.App();
const clusterArn = 'arn:aws:kafka:us-west-2:123456789012:cluster/my-cluster/abcdefg-1234-5678-90ab-cdefghijklmn';
const mskCluster = msk.Cluster.fromClusterArn(app, 'mskCluster', clusterArn);
const describeClusterResult = await new AWS.Kafka().describeCluster({ ClusterArn: clusterArn }).promise();
const bootstrapServers = describeClusterResult.ClusterInfo.BootstrapBrokers.join(',');
In this example:
Cluster
class using the fromClusterArn()
method.describeCluster()
method and passing the cluster ARN as a parameter.describeCluster()
result, and assign it to the bootstrapServers
variable.Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-10-22 11:00:00 +0000
Seen: 11 times
Last updated: Dec 17 '21
How can one ensure that sub-classes have uniform method parameters in TypeScript?
Can a TypeScript definition for icon names be provided in MaterialCommunityIcons for React Native?
How can TypeScript be used to save a file in an Excel add-in?
What is the Angular Type script NG Zorro event for radio buttons?
What is the process for implementing a Many to Many relationship using NestJs Sequlize and Mysql2?
What is the method for defining a Fixed length Array in TypeScript?
What difficulties are encountered in the installation of react-router-dom using typescript?