1. Provisioning a dedicated Kafka cluster within a Confluent Cloud environment

    TypeScript

    To provision a dedicated Kafka cluster within a Confluent Cloud environment using Pulumi, you would use the confluentcloud package for Pulumi. The primary resources involved in this process are:

    1. confluentcloud.Environment: Represents the Confluent Cloud environment where your Kafka Cluster will live.
    2. confluentcloud.KafkaCluster: Represents the Kafka Cluster resource.
    3. confluentcloud.Network: Used to define network settings for your Kafka cluster, shall you need them.

    The following TypeScript Pulumi program creates a Confluent Cloud environment and then provisions a dedicated Kafka cluster within that environment. The dedicated cluster requires you to specify the number of Confluent Kafka Units (CKUs) which will determine the capacity and performance characteristics of the cluster.

    Before running this program, ensure that you have the confluentcloud provider setup and configured with the necessary credentials and permissions to create resources within Confluent Cloud.

    import * as pulumi from "@pulumi/pulumi"; import * as confluentcloud from "@pulumi/confluentcloud"; // Create a Confluent Cloud environment const environment = new confluentcloud.Environment("my-environment", { displayName: "MyEnv", // Choose a name for your environment }); // Create a Confluent Cloud dedicated Kafka Cluster const kafkaCluster = new confluentcloud.KafkaCluster("my-kafka-cluster", { environment: { id: environment.id, }, region: "us", // Specify the region where you want the cluster cloud: "AWS", // Specify the cloud provider dedicated: { cku: 1, // Specify the number of Confluent Kafka Units (CKUs) availability: "LOW", // Choose availability settings 'LOW', 'MEDIUM', or 'HIGH' // You can specify additional settings such as encryptionKey or zones if required }, displayName: "MyKafkaCluster", // Choose a name for your Kafka Cluster }); // Export the Kafka Cluster URL to access your cluster export const kafkaClusterEndpoint = kafkaCluster.httpEndpoint;

    In this program, we first import the Pulumi SDK and the confluentcloud provider. We then create a Confluent Cloud environment by constructing an instance of confluentcloud.Environment with a display name parameter.

    Next, we create the Kafka cluster itself using confluentcloud.KafkaCluster, linking it to the previously created environment through its ID. We also specify the region and cloud provider where the cluster will be provisioned and define the cluster as dedicated with a certain number of CKUs.

    Notice that we export the Kafka cluster endpoint at the end of the program. It's the HTTP endpoint that you can use to access your Kafka cluster once it's available.

    You will need the Confluent Cloud provider properly configured for your Pulumi setup, so please ensure that you have the necessary credentials and permissions set up before you run pulumi up to deploy this code.

    To run this Pulumi program:

    • Install Pulumi CLI and set up the Confluent Cloud provider.
    • Save this TypeScript code in a index.ts file.
    • Run pulumi up to create the resources.