Skip to content

GCP.ManagedKafka reference

Source: packages/gcp/src/ManagedKafka/Cluster.ts

A Managed Service for Apache Kafka cluster.

Changing clusterId, location, subnets, or kmsKey replaces the cluster. Capacity, rebalance mode, TLS config, and labels update in place. Provisioning typically takes more than a minute.

Generated name, 3 vCPU / 3 GiB

const cluster = yield* GCP.ManagedKafka.Cluster("Brokers", {});

Explicit id, subnet, and labels

const cluster = yield* GCP.ManagedKafka.Cluster("Brokers", {
clusterId: "app-kafka",
location: "us-central1",
subnets: [
"projects/my-project/regions/us-central1/subnetworks/default",
],
capacityConfig: { vcpuCount: 3, memoryBytes: 3221225472 },
labels: { env: "prod" },
});

Cluster.lookup references a cluster Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared cluster.

const cluster = GCP.ManagedKafka.Cluster.lookup({ clusterId: "my-cluster" });

Source: packages/gcp/src/ManagedKafka/ClustersAcl.ts

An ACL for a Kafka resource pattern on a Managed Kafka cluster.

The ACL id encodes the resource pattern and is immutable. Entries update in place.

Allow all users to describe a topic

const acl = yield* GCP.ManagedKafka.ClustersAcl("OrdersAcl", {
cluster: cluster.name,
aclId: "topic/orders",
aclEntries: [
{
principal: "User:*",
operation: "DESCRIBE",
permissionType: "ALLOW",
host: "*",
},
],
});

Cluster-wide ACL

const acl = yield* GCP.ManagedKafka.ClustersAcl("ClusterAcl", {
cluster: cluster.name,
aclId: "cluster",
aclEntries: [
{
principal: "User:client@my-project.iam.gserviceaccount.com",
operation: "CLUSTER_ACTION",
permissionType: "ALLOW",
host: "*",
},
],
});

ClustersAcl: Looking up an existing clusters acl

Section titled “ClustersAcl: Looking up an existing clusters acl”

ClustersAcl.lookup references a clusters acl Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared clusters acl.

const clustersAcl = GCP.ManagedKafka.ClustersAcl.lookup({
aclId: "my-acl",
cluster: "my-cluster",
});

Source: packages/gcp/src/ManagedKafka/ClustersTopic.ts

A Kafka topic on a Managed Service for Apache Kafka cluster.

Changing topicId, cluster, location, or replicationFactor replaces the topic. partitionCount can only increase. Configs update in place.

Generated name

const topic = yield* GCP.ManagedKafka.ClustersTopic("Events", {
cluster: cluster.name,
});

Explicit id, partitions, and configs

const topic = yield* GCP.ManagedKafka.ClustersTopic("Events", {
cluster: cluster.name,
topicId: "order-events",
partitionCount: 3,
replicationFactor: 3,
configs: { "cleanup.policy": "compact" },
});

ClustersTopic: Looking up an existing clusters topic

Section titled “ClustersTopic: Looking up an existing clusters topic”

ClustersTopic.lookup references a clusters topic Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared clusters topic.

const clustersTopic = GCP.ManagedKafka.ClustersTopic.lookup({
topicId: "my-topic",
cluster: "my-cluster",
});

Source: packages/gcp/src/ManagedKafka/ConnectCluster.ts

A Managed Service for Apache Kafka Connect cluster.

Changing connectClusterId, location, kafkaCluster, or the primary subnet replaces the cluster. Capacity, labels, and worker config update in place. Provisioning typically takes more than a minute.

ConnectCluster: Creating a Connect Cluster

Section titled “ConnectCluster: Creating a Connect Cluster”

Attach to a Kafka cluster

const connect = yield* GCP.ManagedKafka.ConnectCluster("Connect", {
kafkaCluster: cluster.name,
});

Explicit id and labels

const connect = yield* GCP.ManagedKafka.ConnectCluster("Connect", {
connectClusterId: "app-connect",
kafkaCluster: cluster.name,
labels: { env: "prod" },
});

ConnectCluster: Looking up an existing connect cluster

Section titled “ConnectCluster: Looking up an existing connect cluster”

ConnectCluster.lookup references a connect cluster Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared connect cluster.

const connectCluster = GCP.ManagedKafka.ConnectCluster.lookup({
connectClusterId: "my-connect-cluster",
});

Source: packages/gcp/src/ManagedKafka/ConnectClustersConnector.ts

A Kafka Connect connector on a Managed Kafka Connect cluster.

Changing connectorId, connectCluster, or location replaces the connector. Configs and the task restart policy update in place.

ConnectClustersConnector: Creating a Connector

Section titled “ConnectClustersConnector: Creating a Connector”
const connector = yield* GCP.ManagedKafka.ConnectClustersConnector(
"Sink",
{
connectCluster: connect.name,
configs: {
"connector.class":
"com.google.pubsub.kafka.sink.CloudPubSubSinkConnector",
"tasks.max": "1",
topics: "orders",
"cps.project": "my-project",
"cps.topic": "orders-sink",
},
},
);

ConnectClustersConnector: Looking up an existing connect clusters connector

Section titled “ConnectClustersConnector: Looking up an existing connect clusters connector”

ConnectClustersConnector.lookup references a connect clusters connector Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared connect clusters connector.

const connectClustersConnector = GCP.ManagedKafka.ConnectClustersConnector.lookup({
connectorId: "my-connector",
connectCluster: "my-connect-cluster",
});

Source: packages/gcp/src/ManagedKafka/GetCluster.ts

Runtime binding for Managed Kafka clusters.get.

Bind this operation to a Cluster in a Function/Action init phase. Provide GetClusterHttp.

const getCluster = yield* GCP.ManagedKafka.GetCluster(cluster);
const live = yield* getCluster();

Source: packages/gcp/src/ManagedKafka/GetClusterHttp.ts Kind: Layer · Provides: GCP.ManagedKafka.GetCluster

HTTP implementation of GetCluster.

Source: packages/gcp/src/ManagedKafka/GetConnectCluster.ts

Runtime binding for Managed Kafka connectClusters.get.

Bind this operation to a ConnectCluster in a Function/Action init phase. Provide GetConnectClusterHttp.

GetConnectCluster: Observing Connect Clusters

Section titled “GetConnectCluster: Observing Connect Clusters”
const getConnect = yield* GCP.ManagedKafka.GetConnectCluster(connect);
const live = yield* getConnect();

Source: packages/gcp/src/ManagedKafka/GetConnectClusterHttp.ts Kind: Layer · Provides: GCP.ManagedKafka.GetConnectCluster

HTTP implementation of GetConnectCluster.

Source: packages/gcp/src/ManagedKafka/GetSchemaRegistry.ts

Runtime binding for Managed Kafka schemaRegistries.get.

Bind this operation to a SchemaRegistry in a Function/Action init phase. Provide GetSchemaRegistryHttp.

Grants roles/managedkafka.schemaRegistryViewer (read-only) on the project: schema-registry permission checks do not honor an IAM Condition scoped to the registry’s resource name.

GetSchemaRegistry: Observing Schema Registries

Section titled “GetSchemaRegistry: Observing Schema Registries”
const getRegistry = yield* GCP.ManagedKafka.GetSchemaRegistry(registry);
const live = yield* getRegistry();

Source: packages/gcp/src/ManagedKafka/GetSchemaRegistryHttp.ts Kind: Layer · Provides: GCP.ManagedKafka.GetSchemaRegistry

HTTP implementation of GetSchemaRegistry.

Source: packages/gcp/src/ManagedKafka/GetTopic.ts

Runtime binding for Managed Kafka topics.get.

Bind this operation to a ClustersTopic in a Function/Action init phase. Provide GetTopicHttp.

const getTopic = yield* GCP.ManagedKafka.GetTopic(topic);
const live = yield* getTopic();

Source: packages/gcp/src/ManagedKafka/GetTopicHttp.ts Kind: Layer · Provides: GCP.ManagedKafka.GetTopic

HTTP implementation of GetTopic.

Source: packages/gcp/src/ManagedKafka/SchemaRegistriesContextsSubjectsVersion.ts

A schema version under a subject in a named context of a Managed Kafka schema registry.

Versions are immutable. Changing context, subject, registry, schema, type, or version replaces the resource.

SchemaRegistriesContextsSubjectsVersion: Creating a Version

Section titled “SchemaRegistriesContextsSubjectsVersion: Creating a Version”
const version =
yield* GCP.ManagedKafka.SchemaRegistriesContextsSubjectsVersion(
"OrderSchema",
{
schemaRegistry: registry.name,
context: "prod",
subject: "orders",
schemaType: "AVRO",
schema: JSON.stringify({
type: "record",
name: "Order",
fields: [{ name: "id", type: "string" }],
}),
},
);

Source: packages/gcp/src/ManagedKafka/SchemaRegistriesSubjectsVersion.ts

A schema version under a subject in a Managed Kafka schema registry (default context).

Versions are immutable. Changing subject, registry, schema, type, or version replaces the resource.

SchemaRegistriesSubjectsVersion: Creating a Version

Section titled “SchemaRegistriesSubjectsVersion: Creating a Version”
const version = yield* GCP.ManagedKafka.SchemaRegistriesSubjectsVersion(
"OrderSchema",
{
schemaRegistry: registry.name,
subject: "orders",
schemaType: "AVRO",
schema: JSON.stringify({
type: "record",
name: "Order",
fields: [{ name: "id", type: "string" }],
}),
},
);

SchemaRegistriesSubjectsVersion: Looking up an existing schema registries subjects version

Section titled “SchemaRegistriesSubjectsVersion: Looking up an existing schema registries subjects version”

SchemaRegistriesSubjectsVersion.lookup references a schema registries subjects version Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared schema registries subjects version.

const schemaRegistriesSubjectsVersion = GCP.ManagedKafka.SchemaRegistriesSubjectsVersion.lookup({
subject: "my-subject",
schemaRegistry: "my-schema-registry",
});

Source: packages/gcp/src/ManagedKafka/SchemaRegistry.ts

A Managed Kafka schema registry instance.

Schema registries have no labels field, so Alchemy stamps ownership on a reserved alchemy_ownership subject. Name and location are identity — changing either replaces the registry.

SchemaRegistry: Creating a Schema Registry

Section titled “SchemaRegistry: Creating a Schema Registry”

Generated name

const registry = yield* GCP.ManagedKafka.SchemaRegistry("Schemas", {});

Explicit id

const registry = yield* GCP.ManagedKafka.SchemaRegistry("Schemas", {
schemaRegistryId: "app_schemas",
location: "us-central1",
});

SchemaRegistry: Looking up an existing schema registry

Section titled “SchemaRegistry: Looking up an existing schema registry”

SchemaRegistry.lookup references a schema registry Alchemy doesn’t manage (created in the console or by another stack). It is read during plan/deploy, never created, updated or deleted, and binds like a declared schema registry.

const schemaRegistry = GCP.ManagedKafka.SchemaRegistry.lookup({
schemaRegistryId: "my-schema-registry",
});