Skip to main content

The CDK Construct Library for AWS::MSK

Project description

Amazon Managed Streaming for Apache Kafka Construct Library

---

cdk-constructs: Experimental

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


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.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_msk as msk

cluster = Cluster(self, "Cluster",
    kafka_version=msk.KafkaVersion.V2_8_1,
    vpc=vpc
)

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.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_msk as msk
import aws_cdk.aws_ec2 as ec2

cluster = msk.Cluster(self, "Cluster", ...)

cluster.connections.allow_from(
    ec2.Peer.ipv4("1.2.3.4/8"),
    ec2.Port.tcp(2181))
cluster.connections.allow_from(
    ec2.Peer.ipv4("1.2.3.4/8"),
    ec2.Port.tcp(9094))

Cluster Endpoints

You can use the following attributes to get a list of the Kafka broker or ZooKeeper node endpoints

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
cdk.CfnOutput(self, "BootstrapBrokers", value=cluster.bootstrap_brokers)
cdk.CfnOutput(self, "BootstrapBrokersTls", value=cluster.bootstrap_brokers_tls)
cdk.CfnOutput(self, "BootstrapBrokersSaslScram", value=cluster.bootstrap_brokers_sasl_scram)
cdk.CfnOutput(self, "ZookeeperConnection", value=cluster.zookeeper_connection_string)
cdk.CfnOutput(self, "ZookeeperConnectionTls", value=cluster.zookeeper_connection_string_tls)

Importing an existing Cluster

To import an existing MSK cluster into your CDK app use the .fromClusterArn() method.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
cluster = msk.Cluster.from_cluster_arn(self, "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.

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_msk as msk
import aws_cdk.aws_acmpca as acmpca

cluster = msk.Cluster(self, "Cluster", ClusterProps(
    (SpreadAssignment ...
        encryptionInTransit
      encryption_in_transit)
), {
    "client_broker": msk.ClientBrokerEncryption.TLS
}, client_authentication, msk.ClientAuthentication.tls(
    certificate_authorities=[
        acmpca.CertificateAuthority.from_certificate_authority_arn(stack, "CertificateAuthority", "arn:aws:acm-pca:us-west-2:1234567890:certificate-authority/11111111-1111-1111-1111-111111111111")
    ]
))

SASL/SCRAM

Enable client authentication with SASL/SCRAM:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_msk as msk

cluster = msk.cluster(self, "cluster", {
    (SpreadAssignment ...
      encryptionInTransit
      encryption_in_transit)
}, {
    "client_broker": msk.ClientBrokerEncryption.TLS
}, client_authentication, msk.ClientAuthentication.sasl(
    scram=True
))

SASL/IAM

Enable client authentication with IAM:

# Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
import aws_cdk.aws_msk as msk

cluster = msk.cluster(self, "cluster", {
    (SpreadAssignment ...
      encryptionInTransit
      encryption_in_transit)
}, {
    "client_broker": msk.ClientBrokerEncryption.TLS
}, client_authentication, msk.ClientAuthentication.sasl(
    iam=True
))

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws-cdk.aws-msk-alpha-2.0.0a6.tar.gz (318.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cdk.aws_msk_alpha-2.0.0a6-py3-none-any.whl (317.4 kB view details)

Uploaded Python 3

File details

Details for the file aws-cdk.aws-msk-alpha-2.0.0a6.tar.gz.

File metadata

  • Download URL: aws-cdk.aws-msk-alpha-2.0.0a6.tar.gz
  • Upload date:
  • Size: 318.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5

File hashes

Hashes for aws-cdk.aws-msk-alpha-2.0.0a6.tar.gz
Algorithm Hash digest
SHA256 6a5316d3b22c57011b8e2aeaa00dc832735491c2a31bcc54d43859ad32e04851
MD5 24589413f07f47657d43d164436a6ff4
BLAKE2b-256 5ed59a1c4efa2a58615889fbbafd45e7c89d8a6be420e953d84b6b86708dac4f

See more details on using hashes here.

File details

Details for the file aws_cdk.aws_msk_alpha-2.0.0a6-py3-none-any.whl.

File metadata

  • Download URL: aws_cdk.aws_msk_alpha-2.0.0a6-py3-none-any.whl
  • Upload date:
  • Size: 317.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5

File hashes

Hashes for aws_cdk.aws_msk_alpha-2.0.0a6-py3-none-any.whl
Algorithm Hash digest
SHA256 5eb393efda2af2537a9230c0c665af5c669b8d9d885c6d8f7f0c295ae02ff27a
MD5 d29c59cc47ac0b57ddbd288d49f5c280
BLAKE2b-256 22a4df53e59b41d68cb311fcea3d77d891d8b721478e4d7313467eb519ac7a75

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page