Cloud.KafkaUser
A user of a managed Kafka cluster that clients sign in as with
SCRAM (SASL_SSL, SCRAM-SHA-512), with the topics it can use. Every
cluster also comes with a default user that can use every topic; it
can’t be deleted, and this resource doesn’t manage it (nor lists it).
privileges change in place: up to 25 entries, each a topic name or a
prefix ending in * (* alone is every topic) and a permission of
consume, produce or produce_consume; an empty list allows nothing.
username, kafkaId and availabilityZone replace the user. A user is
gone with its cluster.
Connecting. The attributes carry everything a client needs:
bootstrapServers, securityProtocol, saslMechanism, this username,
its password (Redacted), caCertificate and the ready-made
properties, read from the user’s credentials endpoint.
Credentials: the deploy never resets the password on its own. Set
rotateCredentials to a new value to reset it once; a reset done in the
console or CLI is read on the next deploy, without a replace.
Zone. A child doesn’t take its zone from its parent: it uses its own
availabilityZone, else the credentials’ zone. When the parent lives in
another zone, pass the parent’s along (availabilityZone: parent.availabilityZone), or every call for it answers NotFound.
Creating a user
Section titled “Creating a user”A consumer of every orders.* topic
const kafka = yield* BetterStack.Cloud.Kafka("events", { type: "KA1", brokerCount: 3 });const consumer = yield* BetterStack.Cloud.KafkaUser("consumer", { kafkaId: kafka.id, username: "orders-consumer", privileges: [{ topicPattern: "orders.*", permission: "consume" }],});Its settings in a Cloud.Service’s environment
// env: {// KAFKA_BROKERS: consumer.bootstrapServers,// KAFKA_USERNAME: consumer.username,// KAFKA_PASSWORD: consumer.password,// }Looking up an existing user
Section titled “Looking up an existing user”Reference a user by cluster and id
const existing = BetterStack.Cloud.KafkaUser.lookup({ kafkaId: "42", id: "7" });kafkaId string required
The ID of the parent this kafka belongs to.
availabilityZone string
Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.
privileges CreateKafkaUserRequestPrivilegesItem[]
The topics the user can use and what it can do on them, up to 25 entries. A user with no privileges has an empty list.
rotateCredentials string
Rotate the credentials: every change of this value after create (for example a date, "2026-12") calls the API's rotate operation once on the next deploy, and the new secrets replace the old ones in the attributes (and so in every env that references them). Leaving it out, or keeping the same value, never rotates. A rotation done in the console or CLI is simply read on the next deploy.
username string
The name clients sign in with, unique in the cluster: up to 64 lowercase letters, digits, hyphens and underscores, starting with a letter or digit, not starting with betterstack. Defaults to a unique name generated from the stack, stage and logical id. Changing it replaces the user.
Attributes
Section titled “Attributes”availabilityZone string always set
Availability zone the resource lives in, such as us-west-2a.
bootstrapServers string always set
The cluster's private bootstrap address, host:port.
caCertificate string always set
The CA certificate bundle (PEM) that signs the brokers' TLS certificates.
id string always set
The user's ID.
kafkaId string always set
The ID of the Kafka cluster the user belongs to.
password Redacted<string> always set
The user's SCRAM password (credentials password).
properties KafkaClientProperties always set
The client settings under their librdkafka names, sasl.password Redacted.
publicBootstrapServers string always set
The public bootstrap address, undefined unless the cluster's publicAccess is on.
saslMechanism string always set
The SASL mechanism, SCRAM-SHA-512.
securityProtocol string always set
Always SASL_SSL.
username string always set
The name clients sign in with (sasl.username).
createdAt string | null
When the user was created.
defaultUser boolean
Whether this is the cluster's default user, which every cluster comes with. You can't delete the default user, but you can change its privileges.
privileges KafkaUserPrivilegesItem[]
The topics the user can use and what it can do on them, up to 25 entries. A user with no privileges has an empty list.
updatedAt string | null
When the user was last updated.
Lookup
Section titled “Lookup”KafkaUser.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
id string required
The user's ID (not its username).
kafkaId string required
The ID of the Kafka cluster.
availabilityZone string
Zone the cluster lives in. Defaults to the credentials' zone.
See also
Section titled “See also”- Ownership. The API keeps no
metadatafor it, so the generatedname(it ends in the resource instance’s random suffix) is what identifies an object this stack created: a create interrupted before its state was saved is found by that name on the next deploy. An explicitly named object can’t be told apart from someone else’s (it is taken over only with--adopt), andlistreturns every object. - https://betterstack.com/docs/cloud/api/kafka-users/credentials-kafka-user/