Package software.amazon.awscdk.services.msk
Amazon Managed Streaming for Apache Kafka Construct Library
---
AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
Amazon 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.
The following example creates an MSK Cluster.
Vpc vpc; Cluster cluster = Cluster.Builder.create(this, "Cluster") .clusterName("myCluster") .kafkaVersion(KafkaVersion.V2_8_1) .vpc(vpc) .build();
Allowing Connections
To control who can access the Cluster, use the .connections
attribute. For a list of ports used by MSK, refer to the MSK documentation.
Vpc vpc; Cluster cluster = Cluster.Builder.create(this, "Cluster") .clusterName("myCluster") .kafkaVersion(KafkaVersion.V2_8_1) .vpc(vpc) .build(); cluster.connections.allowFrom(Peer.ipv4("1.2.3.4/8"), Port.tcp(2181)); cluster.connections.allowFrom(Peer.ipv4("1.2.3.4/8"), Port.tcp(9094));
Cluster Endpoints
You can use the following attributes to get a list of the Kafka broker or ZooKeeper node endpoints
Cluster cluster; CfnOutput.Builder.create(this, "BootstrapBrokers").value(cluster.getBootstrapBrokers()).build(); CfnOutput.Builder.create(this, "BootstrapBrokersTls").value(cluster.getBootstrapBrokersTls()).build(); CfnOutput.Builder.create(this, "BootstrapBrokersSaslScram").value(cluster.getBootstrapBrokersSaslScram()).build(); CfnOutput.Builder.create(this, "ZookeeperConnection").value(cluster.getZookeeperConnectionString()).build(); CfnOutput.Builder.create(this, "ZookeeperConnectionTls").value(cluster.getZookeeperConnectionStringTls()).build();
Importing an existing Cluster
To import an existing MSK cluster into your CDK app use the .fromClusterArn()
method.
ICluster cluster = Cluster.fromClusterArn(this, "Cluster", "arn:aws:kafka:us-west-2:1234567890:cluster/a-cluster/11111111-1111-1111-1111-111111111111-1");
Client Authentication
MSK supports the following authentication mechanisms.
Only one authentication method can be enabled.
TLS
To enable client authentication with TLS set the certificateAuthorityArns
property to reference your ACM Private CA. More info on Private CAs.
import software.amazon.awscdk.services.acmpca.*; Vpc vpc; Cluster cluster = Cluster.Builder.create(this, "Cluster") .clusterName("myCluster") .kafkaVersion(KafkaVersion.V2_8_1) .vpc(vpc) .encryptionInTransit(EncryptionInTransitConfig.builder() .clientBroker(ClientBrokerEncryption.TLS) .build()) .clientAuthentication(ClientAuthentication.tls(TlsAuthProps.builder() .certificateAuthorities(List.of(CertificateAuthority.fromCertificateAuthorityArn(this, "CertificateAuthority", "arn:aws:acm-pca:us-west-2:1234567890:certificate-authority/11111111-1111-1111-1111-111111111111"))) .build())) .build();
SASL/SCRAM
Enable client authentication with SASL/SCRAM:
Vpc vpc; Cluster cluster = Cluster.Builder.create(this, "cluster") .clusterName("myCluster") .kafkaVersion(KafkaVersion.V2_8_1) .vpc(vpc) .encryptionInTransit(EncryptionInTransitConfig.builder() .clientBroker(ClientBrokerEncryption.TLS) .build()) .clientAuthentication(ClientAuthentication.sasl(SaslAuthProps.builder() .scram(true) .build())) .build();
SASL/IAM
Enable client authentication with IAM:
Deprecated: AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2. For more information on how to migrate, see https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.htmlVpc vpc; Cluster cluster = Cluster.Builder.create(this, "cluster") .clusterName("myCluster") .kafkaVersion(KafkaVersion.V2_8_1) .vpc(vpc) .encryptionInTransit(EncryptionInTransitConfig.builder() .clientBroker(ClientBrokerEncryption.TLS) .build()) .clientAuthentication(ClientAuthentication.sasl(SaslAuthProps.builder() .iam(true) .build())) .build();
-
ClassDescription(experimental) Configuration details related to broker logs.A builder for
BrokerLogging
An implementation forBrokerLogging
A CloudFormationAWS::MSK::BatchScramSecret
.A fluent builder forCfnBatchScramSecret
.Properties for defining aCfnBatchScramSecret
.A builder forCfnBatchScramSecretProps
An implementation forCfnBatchScramSecretProps
A CloudFormationAWS::MSK::Cluster
.The broker logs configuration for this MSK cluster.A builder forCfnCluster.BrokerLogsProperty
An implementation forCfnCluster.BrokerLogsProperty
Describes the setup to be used for the broker nodes in the cluster.A builder forCfnCluster.BrokerNodeGroupInfoProperty
An implementation forCfnCluster.BrokerNodeGroupInfoProperty
A fluent builder forCfnCluster
.Includes all client authentication information.A builder forCfnCluster.ClientAuthenticationProperty
An implementation forCfnCluster.ClientAuthenticationProperty
Details of the CloudWatch Logs destination for broker logs.A builder forCfnCluster.CloudWatchLogsProperty
An implementation forCfnCluster.CloudWatchLogsProperty
Specifies the configuration to use for the brokers.A builder forCfnCluster.ConfigurationInfoProperty
An implementation forCfnCluster.ConfigurationInfoProperty
Broker access controls.A builder forCfnCluster.ConnectivityInfoProperty
An implementation forCfnCluster.ConnectivityInfoProperty
Contains information about the EBS storage volumes attached to the broker nodes.A builder forCfnCluster.EBSStorageInfoProperty
An implementation forCfnCluster.EBSStorageInfoProperty
The data-volume encryption details.A builder forCfnCluster.EncryptionAtRestProperty
An implementation forCfnCluster.EncryptionAtRestProperty
Includes encryption-related information, such as the Amazon KMS key used for encrypting data at rest and whether you want MSK to encrypt your data in transit.A builder forCfnCluster.EncryptionInfoProperty
An implementation forCfnCluster.EncryptionInfoProperty
The settings for encrypting data in transit.A builder forCfnCluster.EncryptionInTransitProperty
An implementation forCfnCluster.EncryptionInTransitProperty
Firehose details for BrokerLogs.A builder forCfnCluster.FirehoseProperty
An implementation forCfnCluster.FirehoseProperty
Details for SASL/IAM client authentication.A builder forCfnCluster.IamProperty
An implementation forCfnCluster.IamProperty
Indicates whether you want to enable or disable the JMX Exporter.A builder forCfnCluster.JmxExporterProperty
An implementation forCfnCluster.JmxExporterProperty
You can configure your MSK cluster to send broker logs to different destination types.A builder forCfnCluster.LoggingInfoProperty
An implementation forCfnCluster.LoggingInfoProperty
Indicates whether you want to enable or disable the Node Exporter.A builder forCfnCluster.NodeExporterProperty
An implementation forCfnCluster.NodeExporterProperty
JMX and Node monitoring for the MSK cluster.A builder forCfnCluster.OpenMonitoringProperty
An implementation forCfnCluster.OpenMonitoringProperty
Prometheus settings for open monitoring.A builder forCfnCluster.PrometheusProperty
An implementation forCfnCluster.PrometheusProperty
Contains information about provisioned throughput for EBS storage volumes attached to kafka broker nodes.A builder forCfnCluster.ProvisionedThroughputProperty
An implementation forCfnCluster.ProvisionedThroughputProperty
Broker access controls.A builder forCfnCluster.PublicAccessProperty
An implementation forCfnCluster.PublicAccessProperty
The details of the Amazon S3 destination for broker logs.A builder forCfnCluster.S3Property
An implementation forCfnCluster.S3Property
Details for client authentication using SASL.A builder forCfnCluster.SaslProperty
An implementation forCfnCluster.SaslProperty
Details for SASL/SCRAM client authentication.A builder forCfnCluster.ScramProperty
An implementation forCfnCluster.ScramProperty
Contains information about storage volumes attached to Amazon MSK broker nodes.A builder forCfnCluster.StorageInfoProperty
An implementation forCfnCluster.StorageInfoProperty
Details for client authentication using TLS.A builder forCfnCluster.TlsProperty
An implementation forCfnCluster.TlsProperty
Details for allowing no client authentication.A builder forCfnCluster.UnauthenticatedProperty
An implementation forCfnCluster.UnauthenticatedProperty
Includes all client authentication information for VpcConnectivity.A builder forCfnCluster.VpcConnectivityClientAuthenticationProperty
An implementation forCfnCluster.VpcConnectivityClientAuthenticationProperty
Details for SASL/IAM client authentication for VpcConnectivity.A builder forCfnCluster.VpcConnectivityIamProperty
An implementation forCfnCluster.VpcConnectivityIamProperty
VPC connection control settings for brokers.A builder forCfnCluster.VpcConnectivityProperty
An implementation forCfnCluster.VpcConnectivityProperty
Details for client authentication using SASL for VpcConnectivity.A builder forCfnCluster.VpcConnectivitySaslProperty
An implementation forCfnCluster.VpcConnectivitySaslProperty
Details for SASL/SCRAM client authentication for vpcConnectivity.A builder forCfnCluster.VpcConnectivityScramProperty
An implementation forCfnCluster.VpcConnectivityScramProperty
Details for client authentication using TLS for vpcConnectivity.A builder forCfnCluster.VpcConnectivityTlsProperty
An implementation forCfnCluster.VpcConnectivityTlsProperty
A CloudFormationAWS::MSK::ClusterPolicy
.A fluent builder forCfnClusterPolicy
.Properties for defining aCfnClusterPolicy
.A builder forCfnClusterPolicyProps
An implementation forCfnClusterPolicyProps
Properties for defining aCfnCluster
.A builder forCfnClusterProps
An implementation forCfnClusterProps
A CloudFormationAWS::MSK::Configuration
.A fluent builder forCfnConfiguration
.Properties for defining aCfnConfiguration
.A builder forCfnConfigurationProps
An implementation forCfnConfigurationProps
A CloudFormationAWS::MSK::ServerlessCluster
.A fluent builder forCfnServerlessCluster
.Includes all client authentication information.A builder forCfnServerlessCluster.ClientAuthenticationProperty
An implementation forCfnServerlessCluster.ClientAuthenticationProperty
Details for SASL/IAM client authentication.A builder forCfnServerlessCluster.IamProperty
An implementation forCfnServerlessCluster.IamProperty
Details for client authentication using SASL.A builder forCfnServerlessCluster.SaslProperty
An implementation forCfnServerlessCluster.SaslProperty
Example:A builder forCfnServerlessCluster.VpcConfigProperty
An implementation forCfnServerlessCluster.VpcConfigProperty
Properties for defining aCfnServerlessCluster
.A builder forCfnServerlessClusterProps
An implementation forCfnServerlessClusterProps
A CloudFormationAWS::MSK::VpcConnection
.A fluent builder forCfnVpcConnection
.Properties for defining aCfnVpcConnection
.A builder forCfnVpcConnectionProps
An implementation forCfnVpcConnectionProps
(experimental) Configuration properties for client authentication.(experimental) Indicates the encryption setting for data in transit between clients and brokers.(experimental) Create a MSK Cluster.(experimental) A fluent builder forCluster
.(experimental) The Amazon MSK configuration to use for the cluster.A builder forClusterConfigurationInfo
An implementation forClusterConfigurationInfo
(experimental) The level of monitoring for the MSK cluster.(experimental) Properties for a MSK Cluster.A builder forClusterProps
An implementation forClusterProps
(experimental) EBS volume information.A builder forEbsStorageInfo
An implementation forEbsStorageInfo
(experimental) The settings for encrypting data in transit.A builder forEncryptionInTransitConfig
An implementation forEncryptionInTransitConfig
(experimental) Represents a MSK Cluster.Internal default implementation forICluster
.A proxy class which represents a concrete javascript instance of this type.(experimental) Kafka cluster version.(experimental) Monitoring Configuration.A builder forMonitoringConfiguration
An implementation forMonitoringConfiguration
(experimental) Details of the Amazon S3 destination for broker logs.A builder forS3LoggingConfiguration
An implementation forS3LoggingConfiguration
(experimental) SASL authentication properties.A builder forSaslAuthProps
An implementation forSaslAuthProps
(experimental) TLS authentication properties.A builder forTlsAuthProps
An implementation forTlsAuthProps