Under enforcement a REST route no vendored model names runs unchecked, and Amazon MSK was among them: any caller could
create, describe, update or delete a cluster or a configuration. MSK's model routes are vendored
(regen_rest_routes.MODELS), so each request is checked as its operation's action, and kafka joins the generated tables
of request resources, passed roles and tags on create: a cluster, configuration, replicator, VPC connection or topic by
the ARN its path or body gives, CreateReplicator's and CreateChannel's service execution roles passed to kafka, and the
tags a create carries.
A JSON request carries a body member by its botocore locationName where one renames it, as MSK's do (Name is name on the
wire, ConfigurationInfo.Arn is configurationInfo.arn), and MSK's handler reads that name, so regen_iam_request_resources
names each body member path it reads as the request carries it (wire_named): a create is checked on the configuration or
cluster of the name MSK makes, and a body naming another under the botocore spelling too is checked on the one MSK
reads. GuardDuty's CreateFilter name and UpdatePublishingDestination destinationProperties, and API Gateway v2's portal
members, are read as their requests carry them too.
CreateClusterV2 names the configuration its brokers start from two structures deep (provisioned.configurationInfo.arn),
of a type the Service Reference lists for it, and the table read ARN members at most one structure deep, so
regen_iam_request_resources._nested_arns now reads too the members ending in Arn or Arns, holding a string, of a
top-level structure's structures, from botocore alone. 107 operations of other namespaces gain such a row; each ARN is
checked as one of the operation's types where it fits one and dropped where it does not, as one level deep already is,
so most (a KMS key, a role or a bucket naming no type of the action) change nothing. Those that do: Glue's CreateCatalog
and UpdateCatalog on their target catalog, EC2's RunInstances on the resource group a capacity reservation target names,
and Amazon Managed Service for Prometheus' CreateScraper on its workspace and EKS cluster and UpdateScraper on its
workspace. A create checks the tags it carries on what it makes alone, which the table marks by the type its name gives
past its verb; CreateClusterV2's subject, ClusterV2, names no type, so with_made now reads a subject named with a
version that names none without it, and CreateClusterV2 makes a cluster as CreateCluster does: a tagged create needs
kafka:TagResource on the new cluster, not on the configuration it names. A resource the request names by its ARN, or the
service's default a row stands for, exists already, so with_made never counts it as one the create makes, as no such row
of the table was: Glue's tagged CreateCatalog needs glue:TagResource on the catalog it makes, not on the Redshift
catalog it targets. That marks the created row of 95 creates across 38 namespaces; where the created row does not
resolve, the tag check still falls back to every resource the request names, so only a create naming an existing
resource of one of its types by ARN checks its tags on less.
MskStoredResourceArns answers the tags MSK holds on a cluster, read in place in the ARN's account, which an
aws:ResourceTag condition reads where the Service Reference gives the key (a cluster, not a configuration); a tag MSK
keeps with no value is read as an empty one, so it never fails the check.
AWS tags no MSK configuration: CreateConfiguration takes no tags, AWS::MSK::Configuration has none, the Service
Authorization Reference gives a configuration no aws:ResourceTag key and TagResource only assessment, cluster and
vpc-connection, and AWS's evaluation suite notes that TagResource rejects a configuration ARN ("Invalid input resource
arn"). Floci tagged them since #2366, so TagResource, UntagResource and ListTagsForResource now refuse a configuration's
ARN with that BadRequestException, as AWS does, and floci.services.msk.configuration-tags
(FLOCI_SERVICES_MSK_CONFIGURATION_TAGS, off by default) keeps the earlier tagging for state or scripts relying on it;
IAM checks those calls on '*', as no type of the action fits a configuration.
A namespace the table reads is served on its tag routes only at the ARN its path encodes, as Backup's and the others'
are, so MskControllerIntegrationTest's tag calls send the ARN encoded, as the SDKs do, rather than with its '/' raw.
The tables also take the RDS cluster group types (cluster-group, cluster-group-snapshot, cluster-group-auto-backup) AWS
added to the Service Reference on 2026-12-02, on its tagging and restore actions, which the online verify gate reads.
IamRestRouteEnforcementIntegrationTest checks that with no grant a configuration's read is refused, that a grant on one
configuration reads it and refuses another, that an aws:ResourceTag condition reads a cluster's tags, that a cluster
holding a tag with no value is refused rather than answered with a 500, and that CreateConfiguration is checked on the
configuration of the name MSK reads, a body naming another under the botocore spelling too included; that a deny on the
configuration CreateClusterV2 names refuses the create, and that a tagged one needs kafka:TagResource on its new cluster
alone; MskServiceTest and MskControllerIntegrationTest check that a configuration's tag calls are refused unless
configuration-tags is on; IamRequestResourceEnforcementIntegrationTest checks that a deny on the catalog Glue's
CreateCatalog targets refuses it and a deny on tagging that catalog does not refuse a tagged one;
test_regen_iam_request_resources checks the wire names a JSON body path is read by the path read two structures deep,
the type a create named with a version makes, and that no resource named by ARN is made.
11 KiB
MSK (Managed Streaming for Kafka)
Protocol: REST-JSON
Endpoint: http://localhost:4566/
Floci emulates Amazon MSK by orchestrating Redpanda containers. This provides high compatibility with the Kafka API while maintaining a low footprint.
Supported Actions
| Action | Description |
|---|---|
CreateCluster |
Spawns a new Redpanda container for the cluster |
CreateClusterV2 |
Create a provisioned or serverless cluster |
ListClusters |
List all emulated clusters |
ListClustersV2 |
List all emulated clusters using V2 API |
DescribeCluster |
Get cluster metadata and state |
DescribeClusterV2 |
Get cluster metadata and state using V2 API |
DeleteCluster |
Stops and removes the Redpanda container |
GetBootstrapBrokers |
Get the connection strings for the cluster |
BatchAssociateScramSecret |
Associate secret SCRAM credential with cluster |
ListScramSecrets |
List the secret ARNs associated with a cluster |
BatchDisassociateScramSecret |
Remove secret SCRAM credential associated with cluster |
CreateConfiguration |
Create a broker configuration (server.properties) |
ListConfigurations |
List all configurations |
DescribeConfiguration |
Get configuration metadata and latest revision |
DeleteConfiguration |
Delete a configuration |
UpdateConfiguration |
Create a new revision of a configuration |
ListConfigurationRevisions |
List all revisions of a configuration |
DescribeConfigurationRevision |
Get a specific revision, including its server.properties |
ListTagsForResource |
List the tags on a cluster |
TagResource |
Add tags to a cluster |
UntagResource |
Remove tags from a cluster |
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_SERVICES_MSK_ENABLED |
true |
Enable or disable the service |
FLOCI_SERVICES_MSK_MOCK |
false |
true = metadata-only CRUD, no Docker containers |
FLOCI_SERVICES_MSK_DEFAULT_IMAGE |
redpandadata/redpanda:v26.3.1 |
Docker image for Redpanda (Kafka) containers |
FLOCI_SERVICES_MSK_KAFKA_HOST_PORT_BASE |
9300 |
First host port a broker's Kafka listener can be published on |
FLOCI_SERVICES_MSK_KAFKA_HOST_PORT_MAX |
9399 |
Last host port a broker's Kafka listener can be published on |
FLOCI_SERVICES_MSK_SCRAM_RECONCILIATION_INTERVAL_MS |
5000 |
SCRAM secret reconciliation interval (ms) |
FLOCI_SERVICES_MSK_CONFIGURATION_TAGS |
false |
AWS tags no configuration and refuses its ARN on the tag operations (BadRequestException, "Invalid input resource arn"), as Floci does by default; true keeps Floci's earlier tagging of configurations |
FLOCI_SERVICES_MSK_BOOTSTRAP_HOSTNAME |
(unset) | Floci in a container only: hostname the host listener advertises, and when set, GetBootstrapBrokers returns <container-name>:9092,<hostname>:<host port> instead of <container-name>:9092 alone |
How it works
When mock is set to false (default), Floci uses the Docker API to start a Redpanda container for each created cluster. For Docker socket setup, private registry authentication, and other Docker settings see Docker Configuration.
- Networking: Kafka clients connect to whatever address the broker advertises, so the advertised address has to be reachable from the client.
- Floci on the host: the Kafka API (9092) is published on a host port from the
kafka-host-portrange and advertised aslocalhost:<port>. - Floci in a container: the broker has two listeners.
internal(9092) advertises<container-name>:9092for containers on the same Docker network.host(9093) is published on a host port from thekafka-host-portrange and advertised as<bootstrap-hostname or localhost>:<port>for clients on the Docker host.GetBootstrapBrokersreturns<container-name>:9092, the address the internal listener advertises, so a client gets a hostname as it does from AWS rather than a container IP. WhenFLOCI_SERVICES_MSK_BOOTSTRAP_HOSTNAMEis set, it returns both listeners,<container-name>:9092,<hostname>:<port>: a client connects through whichever entry it can reach, and the broker then advertises that listener's address. The two entries are two listeners on the same broker, not two brokers.
- Floci on the host: the Kafka API (9092) is published on a host port from the
- Persistence: Each cluster gets a named Docker volume (
floci-aws-msk-{volumeId}). In memory mode the volume is removed on cluster delete; in persistent modes it is retained unlessFLOCI_STORAGE_PRUNE_VOLUMES_ON_DELETE=true. - Readiness: The cluster state transitions to
ACTIVEonce the Redpanda/readyendpoint is reachable.
Cluster metadata
CreateCluster and CreateClusterV2 persist the metadata you pass — broker node group
(instance type, subnets, security groups, storage, connectivity), number of broker nodes,
encryption, client authentication, enhanced monitoring, open monitoring, logging,
configuration, storage mode, rebalancing and tags —
and echo it back from DescribeCluster/DescribeClusterV2 and the matching List calls.
The two API versions return different shapes, matching AWS:
- v1 (
DescribeCluster) returns a flatClusterInfo:brokerNodeGroupInfo,encryptionInfo,clientAuthentication,enhancedMonitoring,loggingInfo,openMonitoring,storageMode,rebalancing,numberOfBrokerNodesandzookeeperConnectStringall sit directly on the cluster. - v2 (
DescribeClusterV2) nests all of those underClusterInfo.Provisioned, alongside a top-levelClusterTypeofPROVISIONED.ClusterArn,ClusterName,State,CreationTime,CurrentVersionandTagsstay top-level.
Two details worth knowing:
configurationInfois a request-only member. The configuration a cluster was created with is reported back oncurrentBrokerSoftwareInfoasconfigurationArnandconfigurationRevision, which is where the Terraform AWS provider reads it from.- Members AWS defaults server-side are defaulted here too, so a
terraform planconverges:enhancedMonitoringbecomesDEFAULT, andencryptionInfo.encryptionInTransitbecomesclientBroker: TLS/inCluster: truewhen the request omits them.
Serverless clusters
CreateClusterV2 accepts a serverless member as well as provisioned — exactly one of the
two, as on AWS. A serverless cluster stores its vpcConfigs and clientAuthentication, reports
clusterType: SERVERLESS, and comes back from DescribeClusterV2 under a serverless envelope
rather than a provisioned one. It is backed by the same emulated Kafka endpoint, so
GetBootstrapBrokers works normally.
The v1 API predates serverless and its ClusterInfo cannot represent one, so — as on AWS —
DescribeCluster on a serverless cluster returns BadRequestException pointing you at
DescribeClusterV2, and ListClusters omits serverless clusters entirely.
Validation
CreateCluster/CreateClusterV2 reject the values AWS rejects: a missing or over-64-character
clusterName, a numberOfBrokerNodes below 1, an EBS volumeSize outside 1–16384, a
configurationInfo.revision below 1, and any unrecognised enhancedMonitoring, storageMode,
rebalancing.status or encryptionInTransit.clientBroker value. Each 400 names the offending
member in invalidParameter, as MSK's Error schema does.
There is deliberately no upper bound on numberOfBrokerNodes. The SDK model caps it at 15,
but the REST API reference documents no maximum for it — on a page that gives ranges for its
neighbours — and the quota page allows 30 brokers per ZooKeeper cluster and 60 per KRaft
cluster, both adjustable. A 30-broker cluster is an ordinary thing to have.
Unlike AWS, the presence of kafkaVersion, numberOfBrokerNodes and brokerNodeGroupInfo is
not required — the emulator defaults them so that a minimal create request still works.
Tags
Cluster and configuration tags are managed through /v1/tags/{resourceArn}
(ListTagsForResource, TagResource, UntagResource). Cluster tags also round-trip through
DescribeCluster/DescribeClusterV2, so a tag change is visible to a refresh either way.
Configuration tags are reachable only through the tag endpoints, because AWS's
DescribeConfiguration response has no tags member.
SCRAM Secrets Association
Manages credentials only: the broker does not enable SASL authentication or validate these users when clients connect. Clients can still connect without credentials. Authenticated SASL_SSL listeners is not implemented.
BatchAssociateScramSecret accepts up to 10 Secrets Manager ARNs and creates kafka
SCRAM-SHA-512 users.
Secrets must belong to the cluster's account, region and partition, use the AmazonMSK_
name prefix and a customer-managed symmetric KMS key ID, not an alias/... reference.
The secrets must contain JSON such as {"username":"alice","password":"pw"}.
ListScramSecrets supports pagination. BatchDisassociateScramSecret removes up to
10 associations. Item failures appear in
unprocessedScramSecrets; reassociation and removal of an unassociated ARN return
InvalidSecretArn.
Floci schedules SCRAM reconciliation jobs every five seconds by default, measured as
a delay after each scheduling sweep. Sweeps do not wait for broker operations to finish,
and clusters with queued or running jobs are skipped. Set
FLOCI_SERVICES_MSK_SCRAM_RECONCILIATION_INTERVAL_MS to change this delay in milliseconds.
This is Floci's timing, not an AWS synchronization guarantee.
When an associated secret is scheduled for deletion or permanently deleted, reconciliation
revokes its broker user but retains the association in ListScramSecrets. Restoring a secret
whose deletion was scheduled causes reconciliation to recreate its broker user using the
current credentials, without requiring reassociation. Permanently deleted secrets cannot
be restored; creating a secret with the same name produces a different ARN and requires
a new association.
Examples
export AWS_ENDPOINT_URL=http://localhost:4566
# Create a cluster
aws kafka create-cluster \
--cluster-name my-cluster \
--kafka-version "3.6.1" \
--number-of-broker-nodes 1 \
--broker-node-group-info '{"InstanceType":"kafka.m5.large","ClientSubnets":["subnet-1"]}' \
--endpoint-url $AWS_ENDPOINT_URL
# List clusters
aws kafka list-clusters --endpoint-url $AWS_ENDPOINT_URL
# Get bootstrap brokers
CLUSTER_ARN=$(aws kafka list-clusters --query 'ClusterInfoList[0].ClusterArn' --output text --endpoint-url $AWS_ENDPOINT_URL)
aws kafka get-bootstrap-brokers --cluster-arn $CLUSTER_ARN --endpoint-url $AWS_ENDPOINT_URL
# Associate an existing secret
aws kafka batch-associate-scram-secret \
--cluster-arn "$CLUSTER_ARN" \
--secret-arn-list "arn:aws:secretsmanager:us-east-1:000000000000:secret:AmazonMSK_my-user" \
--endpoint-url $AWS_ENDPOINT_URL
# Delete a cluster
aws kafka delete-cluster --cluster-arn $CLUSTER_ARN --endpoint-url $AWS_ENDPOINT_URL