Experimental
@aws-cdk/aws-msk-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Cluster L2 construct
Create a MSK Cluster.
Example
declare const vpc: ec2.Vpc;
const cluster = new msk.Cluster(this, 'cluster', {
clusterName: 'myCluster',
kafkaVersion: msk.KafkaVersion.V4_1_X_KRAFT,
vpc,
encryptionInTransit: {
clientBroker: msk.ClientBrokerEncryption.TLS,
},
clientAuthentication: msk.ClientAuthentication.sasl({
scram: true,
}),
});
# vpc: ec2.Vpc
cluster = msk.Cluster(self, "cluster",
cluster_name="myCluster",
kafka_version=msk.KafkaVersion.V4_1_X_KRAFT,
vpc=vpc,
encryption_in_transit=msk.EncryptionInTransitConfig(
client_broker=msk.ClientBrokerEncryption.TLS
),
client_authentication=msk.ClientAuthentication.sasl(
scram=True
)
)
Vpc vpc;
Cluster cluster = Cluster.Builder.create(this, "cluster")
.clusterName("myCluster")
.kafkaVersion(KafkaVersion.V4_1_X_KRAFT)
.vpc(vpc)
.encryptionInTransit(EncryptionInTransitConfig.builder()
.clientBroker(ClientBrokerEncryption.TLS)
.build())
.clientAuthentication(ClientAuthentication.sasl(SaslAuthProps.builder()
.scram(true)
.build()))
.build();
// Install: dotnet add package Amazon.CDK.AWS.MSK.Alpha
Vpc vpc;
var cluster = new Cluster(this, "cluster", new ClusterProps {
ClusterName = "myCluster",
KafkaVersion = KafkaVersion.V4_1_X_KRAFT,
Vpc = vpc,
EncryptionInTransit = new EncryptionInTransitConfig {
ClientBroker = ClientBrokerEncryption.TLS
},
ClientAuthentication = ClientAuthentication.Sasl(new SaslAuthProps {
Scram = true
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdkmskalpha/v2
var vpc Vpc
cluster := msk.NewCluster(this, jsii.String("cluster"), &ClusterProps{
ClusterName: jsii.String("myCluster"),
KafkaVersion: msk.KafkaVersion_V4_1_X_KRAFT(),
Vpc: Vpc,
EncryptionInTransit: &EncryptionInTransitConfig{
ClientBroker: msk.ClientBrokerEncryption_TLS,
},
ClientAuthentication: msk.ClientAuthentication_Sasl(&SaslAuthProps{
Scram: jsii.Boolean(true),
}),
})
Initializer
new Cluster(scope: Construct, id: string, props: ClusterProps)
Cluster(scope: Construct, id: str, props: ClusterProps)
new Cluster(Construct scope, String id, ClusterProps props)
new Cluster(Construct scope, string id, ClusterProps props)
NewCluster(Scope Construct, Id *string, Props ClusterProps)
Construct Props
brokerTypeBrokerTypebroker_typeBrokerTypebrokerTypeBrokerTypeBrokerTypeBrokerTypeBrokerTypeBrokerType= BrokerType.STANDARD#When set to EXPRESS, the cluster will be created with Express Brokers. When this is set to EXPRESS, instanceType must also be specified.
clientAuthenticationClientAuthenticationclient_authenticationClientAuthenticationclientAuthenticationClientAuthenticationClientAuthenticationClientAuthenticationClientAuthenticationClientAuthentication= disabled#MSK supports using private TLS certificates or SASL/SCRAM to authenticate the identity of clients.
configurationInfoClusterConfigurationInfoconfiguration_infoClusterConfigurationInfoconfigurationInfoClusterConfigurationInfoConfigurationInfoClusterConfigurationInfoConfigurationInfoClusterConfigurationInfo= none#ebsStorageInfoEbsStorageInfoebs_storage_infoEbsStorageInfoebsStorageInfoEbsStorageInfoEbsStorageInfoEbsStorageInfoEbsStorageInfoEbsStorageInfo= 1000 GiB EBS volume#encryptionInTransitEncryptionInTransitConfigencryption_in_transitEncryptionInTransitConfigencryptionInTransitEncryptionInTransitConfigEncryptionInTransitEncryptionInTransitConfigEncryptionInTransitEncryptionInTransitConfig= enabled#instanceTypeInstanceTypeinstance_typeInstanceTypeinstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceTypeInstanceType= kafka.m5.large#kafkaVersionKafkaVersionkafka_versionKafkaVersionkafkaVersionKafkaVersionKafkaVersionKafkaVersionKafkaVersionKafkaVersionrequired#loggingBrokerLoggingloggingBrokerLoggingloggingBrokerLoggingLoggingBrokerLoggingLoggingBrokerLogging= disabled#monitoringMonitoringConfigurationmonitoringMonitoringConfigurationmonitoringMonitoringConfigurationMonitoringMonitoringConfigurationMonitoringMonitoringConfiguration= DEFAULT monitoring level#numberOfBrokerNodesnumbernumber_of_broker_nodesint | floatnumberOfBrokerNodesNumberNumberOfBrokerNodesdoubleNumberOfBrokerNodes*float64= 1#removalPolicyRemovalPolicyremoval_policyRemovalPolicyremovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicyRemovalPolicy= RemovalPolicy.RETAIN#securityGroupsISecurityGroup[]security_groupstyping.List[ISecurityGroup]securityGroupsList<ISecurityGroup>SecurityGroupsISecurityGroup[]SecurityGroups*[]ISecurityGroup= create new security group#storageModeStorageModestorage_modeStorageModestorageModeStorageModeStorageModeStorageModeStorageModeStorageMode= StorageMode.LOCAL#Must have at least 2 subnets in two different AZs.
vpcSubnetsSubnetSelectionvpc_subnetsSubnetSelectionvpcSubnetsSubnetSelectionVpcSubnetsSubnetSelectionVpcSubnetsSubnetSelection= the Vpc default strategy if not …#Amazon MSK distributes the broker nodes evenly across the subnets that you specify. The subnets that you specify must be in distinct Availability Zones. Client subnets can't be in Availability Zone us-east-1e.
default
Default: the Vpc default strategy if not specified.
Properties
bootstrapBrokersstringbootstrap_brokersstrbootstrapBrokersStringBootstrapBrokersstringBootstrapBrokers*stringrequired#Uses a Custom Resource to make an API call to getBootstrapBrokers using the Javascript SDK
bootstrapBrokersSaslIamstringbootstrap_brokers_sasl_iamstrbootstrapBrokersSaslIamStringBootstrapBrokersSaslIamstringBootstrapBrokersSaslIam*stringrequired#Uses a Custom Resource to make an API call to getBootstrapBrokers using the Javascript SDK
bootstrapBrokersSaslScramstringbootstrap_brokers_sasl_scramstrbootstrapBrokersSaslScramStringBootstrapBrokersSaslScramstringBootstrapBrokersSaslScram*stringrequired#Uses a Custom Resource to make an API call to getBootstrapBrokers using the Javascript SDK
bootstrapBrokersTlsstringbootstrap_brokers_tlsstrbootstrapBrokersTlsStringBootstrapBrokersTlsstringBootstrapBrokersTls*stringrequired#Uses a Custom Resource to make an API call to getBootstrapBrokers using the Javascript SDK
connectionsConnectionsconnectionsConnectionsconnectionsConnectionsConnectionsConnectionsConnectionsConnectionsrequired#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#saslScramAuthenticationKeyIKeysasl_scram_authentication_keyIKeysaslScramAuthenticationKeyIKeySaslScramAuthenticationKeyIKeySaslScramAuthenticationKeyIKey#zookeeperConnectionStringstringzookeeper_connection_stringstrzookeeperConnectionStringStringZookeeperConnectionStringstringZookeeperConnectionString*stringrequired#Uses a Custom Resource to make an API call to describeCluster using the Javascript SDK
zookeeperConnectionStringTlsstringzookeeper_connection_string_tlsstrzookeeperConnectionStringTlsStringZookeeperConnectionStringTlsstringZookeeperConnectionStringTls*stringrequired#Uses a Custom Resource to make an API call to describeCluster using the Javascript SDK
Methods
addUser(...usernames: string[]): voiddef add_user(self, usernames: str) -> Nonepublic void addUser(String usernames)public void AddUser(string usernames)func AddUser(Usernames *string)#The password will automatically be generated using Secrets Manager and the { username, password } JSON object stored in Secrets Manager as AmazonMSK_username.
Must be using the SASL/SCRAM authentication mechanism.
1 parameter
Parameters
usernamesusernamesusernamesusernamesUsernames— - username(s) to register with the cluster.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromClusterArn(scope: Construct, id: string, clusterArn: string): ICluster@staticmethod def from_cluster_arn(scope: Construct, id: str, cluster_arn: str) -> IClusterpublic static ICluster fromClusterArn(Construct scope, String id, String clusterArn)public static ICluster FromClusterArn(Construct scope, string id, string clusterArn)func FromClusterArn(Scope Construct, Id *string, ClusterArn *string) IClusterstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.