Managing Amazon Msk
AWSOfficialPublished by AWS
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides domain expertise for operating Amazon MSK Provisioned clusters. It covers performance troubleshooting, consumer lag diagnosis, storage management, cluster sizing, client configuration, and CloudWatch monitoring. It distinguishes between Standard and Express broker architectures, providing specific workflows for maintenance, topic management, and MSK Replicator setup. The skill also includes guidance on integrating with S3 via Streaming Tables and Data Delivery for General Purpose S3.
What it does
- Provides configuration patterns for Kafka producers and consumers.
- Offers workflows for managing MSK cluster configurations and custom domain names.
- Includes a sizing script for determining broker counts and instance types.
- Details procedures for MSK Replicator setup for DR and cross-account replication.
- Outlines monitoring and alerting strategies using CloudWatch metrics.
- Guides the setup of Streaming Tables and Data Delivery for S3.
When to use it
- When configuring or tuning Kafka clients for MSK connectivity.
- When sizing a new MSK cluster or choosing between Standard and Express brokers.
- When troubleshooting performance issues, consumer lag, or storage constraints.
- When setting up cross-cluster replication or disaster recovery.
- When integrating MSK with S3 for data lake or streaming table requirements.
Advantages
- Provides clear decision frameworks for Standard vs. Express broker types.
- Includes automated sizing logic via provided scripts.
- Centralizes operational procedures for common MSK maintenance tasks.
- Offers specific guidance for complex configurations like custom advertised listeners.
Usage examples
- “How do I choose between MSK Standard and Express brokers for my workload?”
- The agent will guide you through the size-and-choose-cluster.md reference and run the msk_sizing.py script to compare costs and performance characteristics.
- “My consumer lag is increasing, what should I check?”
- The agent will provide a troubleshooting workflow based on troubleshoot-consumer-lag.md, covering rebalance issues and consumer group health.
- “How do I configure a custom domain name for my MSK brokers?”
- The agent will explain how to use the custom.advertised.listeners configuration property as detailed in configure-cluster.md.
- “What are the recommended producer settings for MSK?”
- The agent will provide the table of recommended values for settings like linger.ms, batch.size, and acks from the configure-clients.md reference.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/aws/managing-amazon-msk/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip managing-amazon-msk.zip -d .agents/skills
Documentation by AWS
Amazon MSK
Overview
Domain expertise for operating Amazon MSK Provisioned clusters with Standard and Express broker types. Covers performance troubleshooting, consumer lag diagnosis, storage management, cluster sizing, client configuration, and CloudWatch monitoring.
Execute commands using available tools from the AWS MCP server when connected — it provides sandboxed execution, audit logging, and observability. When the MCP server is not available, fall back to the AWS CLI or shell as needed.
Standard brokers use customer-managed EBS volumes for storage. You choose instance types (kafka.m5/m7g families), provision EBS, and manage storage scaling.
Express brokers use instance types prefixed with express.m7g and are the default recommendation for almost all MSK workloads — they typically cost less, not just less effort. Up to 3x ingress per broker (MSK Express broker types) means fewer brokers for the same load, and storage is billed per GB-hour on data actually retained rather than provisioned up front on EBS that cannot shrink. They also scale 20x faster, rebalance partitions 180x faster (Intelligent Rebalancing), recover 90% quicker (MSK Express broker types), and have no maintenance windows. Express brokers have NO customer-managed EBS — do NOT recommend EBS expansion or provisioned throughput for Express clusters. Express brokers enforce fixed replication factor of 3 and min.insync.replicas=2. See size-and-choose-cluster.md for the full Standard vs Express decision framework.
Which Workflow Do You Need?
Determine the broker type first: aws kafka describe-cluster-v2 --cluster-arn <arn>. Check Provisioned.BrokerNodeGroupInfo.InstanceType — if it starts with express., it is an Express cluster.
| Customer Intent | Reference |
|---|---|
| High CPU, high latency, slow cluster, traffic shaping | troubleshoot-performance.md |
| Consumer lag increasing, rebalance storms, stuck consumer groups | troubleshoot-consumer-lag.md |
| Disk filling up, retention planning, tiered storage | manage-storage.md |
| Choosing Standard vs Express, sizing a cluster, partition limits, broker count, monthly cost | size-and-choose-cluster.md |
| Producer/consumer configuration, IAM/SCRAM/TLS auth | configure-clients.md |
Creating/applying MSK configurations (server.properties); custom domain names on brokers via custom.advertised.listeners (advertised listeners, static/custom bootstrap endpoint) — validation rules, apply/rollback, scaling; migrating from the dynamic per-broker kafka-configs.sh override to the static property | configure-cluster.md |
| Client-side connectivity for a custom domain: NLB + ACM certificate + Route 53 fronting, TLS handshake/termination, mTLS through an NLB, cross-zone load balancing | configure-clients.md (Custom Domain Name Connectivity section) |
Create, update, delete, list, or describe Kafka topics; when to use the native topic APIs / CfnTopic vs. a Kafka admin client | manage-topics.md |
| MSK Replicator setup, migration, DR, active-active/active-passive, cross-account replication, self-managed-to-MSK or MSK-to-MSK, loop-prevention/topic-naming behavior | msk-replicator.md |
Replication throughput per partition, how many partitions a replicator needs, why replicator scaling isn't increasing throughput, replicator quotas (topics, ingress, record size), ReplicationLatency/MessageLag/ReplicatorThroughput | msk-replicator.md (Size partition count section) |
| Setting up monitoring, dashboards, alarms | monitor-and-alarm.md |
| Full CloudWatch metric list (Standard or Express) | Prefer monitor-and-alarm.md for strategic recommendations and how to interpret metrics, only search documentation if you need to understand a metric not included in this reference file (MSK Standard CloudWatch Metrics, MSK Express CloudWatch Metrics) for full list |
| Rolling restart impact, patching, maintenance resilience | maintenance-operations.md |
| Deliver streaming data to Apache Iceberg tables on S3 Tables with low cost in a fully managed service (Streaming Tables) — setup, IAM, schema, create/update/delete/list/describe channels | streaming-tables.md |
| Deliver topic data to S3 bucket as JSON/ByteArray/String objects with low cost in a fully managed service (Data Delivery for General Purpose S3 buckets) — setup, IAM, output key templates, create/update/delete/list/describe channels | data-delivery-for-general-purpose-s3.md |
| Build a lakehouse / data lake from Kafka; make streaming data queryable in Athena | streaming-tables.md |
| Alternative to Kafka Connect S3 Sink or Amazon Data Firehose for MSK; zero-ops streaming delivery to S3 | data-delivery-for-general-purpose-s3.md |
| Streaming Tables / Data Delivery CloudWatch metrics and alarms, DLQ errors, failed deliveries, channel state transitions, freshness lag | streaming-tables-troubleshooting.md |
| "Can I use Streaming Tables / Data Delivery on MSK Serverless / Standard brokers?" — eligibility routing | streaming-tables.md (answer is always: Express brokers only, use Firehose, Flink, or Kafka Connect for Standard and Serqverless - Firehose integration for Amazon MSK) |
| What are the current supported Kafka versions for MSK? | Supported Apache Kafka versions |
| Does MSK support KRaft clusters, and how do I migrate between ZooKeeper and KRaft mode clusters? | zk-to-kraft-migration.md |
| What are the current quotas for MSK Express (ingress, egress, partitions, broker count, etc.)? | MSK Express Quotas |
| What are the current quotas for MSK Standard (partitions, broker count, etc.)? | MSK Standard Quotas, and MSK Standard best practices for partition count limits |
| What broker-level configuration changes can I make on MSK Express or Standard brokers? | MSK Configuration |
Available scripts
scripts/msk_sizing.py— MUST be run for any sizing question (broker count, instance choice, cost). Prices from the live AWS Pricing API when AWS credentials withpricing:GetProductsare available, and falls back to an embeddedus-east-1snapshot when they are not, so it runs with or without credentials. See size-and-choose-cluster.md for the required workflow and script reference.
Guardrail — where this skill's own files live (MCP vs local install)
This skill can be loaded two ways, and they resolve the skill's own bundled files — the references/ documents and the scripts/ files
from different places. Determine how the skill was loaded before you read a reference or run a script:
Loaded through the AWS MCP
retrieve_skilltool call. The skill is not installed on the local filesystem; its reference files and scripts do not exist on disk. You MUST fetch each reference or script through the sameretrieve_skilltool by passing thefileparameter (for example,file="references/configure-clients.md"orfile="scripts/msk_sizing.py"), and run a script from the content that tool returns. Do NOTfile_readthese paths from the local or working directory, and do NOT search the filesystem for them — they are not there, and any local file that happens to match the name is unrelated to this skill.Installed locally (the skill lives in a local skills directory such as
.claude/skills/managing-amazon-msk/,~/.claude/skills/managing-amazon-msk/, or.kiro/skills/managing-amazon-msk/). Read references and run scripts from the local skill directory using the relative paths shown throughout this documentation.
This distinction applies only to the skill's own packaged files. Every artifact
created during a session or supplied by users are read from and written to
the user's working directory regardless of how the skill was loaded. Never
fetch or write customer data through retrieve_skill.
Common Workflows
Create/apply Amazon MSK configurations and set custom domain names — creating an Amazon MSK configuration (server.properties with the fileb:// real-newline requirement), applying it with update-cluster-configuration, and setting broker custom domain names via custom.advertised.listeners: see configure-cluster.md. For the NLB/certificate/DNS connectivity that fronts a custom domain, see configure-clients.md.
Files
- ATTRIBUTION.mdAdded by AutoGineer918 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer67 B
- SKILL.md11.0 KiB
- references/configure-clients.md13.3 KiB
- references/configure-cluster.md11.3 KiB
- references/data-delivery-for-general-purpose-s3.md15.7 KiB
- references/maintenance-operations.md13.0 KiB
- references/manage-storage.md8.5 KiB
- references/manage-topics.md7.0 KiB
- references/monitor-and-alarm.md15.4 KiB
- references/msk-replicator.md18.9 KiB
- references/size-and-choose-cluster.md17.2 KiB
- references/streaming-tables-troubleshooting.md5.3 KiB
- references/streaming-tables.md19.5 KiB
- references/troubleshoot-consumer-lag.md11.5 KiB
- references/troubleshoot-performance.md9.3 KiB
- references/zk-to-kraft-migration.md728 B
- scripts/msk_sizing.pyScript62.6 KiB
references/configure-clients.md
Configure Kafka Clients for MSK
Producer Configuration
| Setting | Recommended Value | Why |
|---|---|---|
linger.ms | 5 ms minimum; 25 ms for most use cases | NEVER use 0. A value of 0 sends one request per message, saturating broker request handlers. Even low-latency use cases benefit from 5 ms. |
batch.size | 65536 (64 KB) or 131072 (128 KB) | Larger batches reduce request count and broker CPU. Default 16384 is often too small. |
buffer.memory | 67108864 (64 MB) | Increase when using larger batch sizes to avoid BufferExhaustedException. |
compression.type | lz4 or zstd | Reduces network bandwidth and storage. lz4 for low latency; zstd for best compression ratio. |
acks | all | Required for durability with MSK default min.insync.replicas=2 and RF=3. Ensures all in-sync replicas acknowledge. Combined with min.insync.replicas=2, writes succeed as long as at least 2 of 3 replicas are in the ISR. |
retries | 2147483647 (Integer.MAX_VALUE) | Allow unlimited retries. Use delivery.timeout.ms to bound total time. Failure to retry breaks Kafka's high availability during broker failover. |
delivery.timeout.ms | 60000 minimum; 120000 (default) or higher | Upper bound for total send time including retries. Must be ≥ request.timeout.ms + linger.ms. AWS recommends a minimum of 60 seconds. With RF=3 and min.insync.replicas=2, producers only stall during leader election (seconds), so the 2-min default covers most cases. Increase if you observe TimeoutException during maintenance. |
request.timeout.ms | 10000 (10 seconds) or higher | Max wait time for a single request before retry. |
retry.backoff.ms | 200 minimum | Prevents retry storms during broker failover. |
send.buffer.bytes | -1 (OS default) | Let the OS manage TCP buffers, especially on high-latency networks. |
Consumer Configuration
| Setting | Recommended Value | Why |
|---|---|---|
session.timeout.ms | 45000-60000 | Controls how long the broker waits without a heartbeat before evicting the consumer. Higher values tolerate GC pauses and network blips but delay failure detection. When using static membership (group.instance.id), must also exceed expected restart time. |
heartbeat.interval.ms | 10000-15000 | Should be less than 1/3 of session.timeout.ms. Controls how quickly the group coordinator detects consumer failures. |
max.poll.interval.ms | Based on processing time | If message processing takes > 5 minutes, increase this. Default 300000 (5 min). If exceeded, consumer is evicted from the group. |
max.poll.records | Tune to processing capacity | Reduce if processing is slow to avoid exceeding max.poll.interval.ms. |
partition.assignment.strategy | CooperativeStickyAssignor | Enables incremental rebalances instead of stop-the-world. Migration requires two rolling restarts: first deploy with RangeAssignor,CooperativeStickyAssignor, then remove RangeAssignor. Mixing eager and cooperative protocols causes InconsistentGroupProtocolException. |
group.instance.id | Unique per consumer (e.g., hostname, pod-id) | Enables static group membership. Prevents unnecessary rebalances on short consumer restarts. |
auto.offset.reset | latest for new consumer groups | Avoids reprocessing the entire topic on first start, which can overload the cluster. |
auto.commit.interval.ms | 5000 minimum | Prevents excessive commit requests that add broker load. |
fetch.min.bytes | 1024-131072 (1 KB-128 KB) | Reduces number of fetch requests. 1 KB for low-latency use cases; 32-128 KB for throughput-oriented workloads. |
fetch.max.wait.ms | 1000 | How long to wait if fetch.min.bytes is not met. |
client.rack | AZ ID (e.g., use1-az1) | Consumer side. Enables nearest-replica reads to eliminate cross-AZ consumer fetch cost. Must be paired with the broker-side selector in the row below. |
replica.selector.class (cluster configuration) | org.apache.kafka.common.replica.RackAwareReplicaSelector | Broker-side. Default on MSK is null — must be set explicitly by attaching a custom MSK cluster configuration that includes this line, then applying it to the cluster. Without it, client.rack has no effect and consumers still fetch from the partition leader regardless of AZ. broker.rack itself is set automatically by MSK to the broker's AZ ID (e.g., use1-az1) so no manual config is needed there. See Reduce network traffic costs of your Amazon MSK consumers with rack awareness for the full setup. |
isolation.level | read_uncommitted (default) | SHOULD NOT use read_committed when reading from tiered storage unless actively using transactions. |
receive.buffer.bytes | -1 (OS default) | Let OS manage TCP buffers on high-latency networks. |
Connection Management
Create Kafka clients (producer, consumer, admin) once per application lifecycle — use singleton pattern. For AWS Lambda, create the client in global/init scope, NOT inside the handler function.
Add random jitter (random sleep) before creating clients to avoid connection storms during deployments
Add a shutdown hook with a random sleep before closing clients on SIGTERM — this prevents all clients from disconnecting simultaneously during rolling deployments. The random sleep should fit within the window before SIGKILL occurs.
Ensure your deployment mechanism does not restart all producers/consumers at once — deploy in smaller batches
Set
reconnect.backoff.ms = 1000to handle connection retries gracefullyMonitor
connection-count,connection-creation-rate,connection-close-rateclient metrics — these should be stable. High connection creation/termination rates cause unnecessary broker load.
IAM Authentication
MSK IAM auth client configuration:
security.protocol=SASL_SSL
sasl.mechanism=AWS_MSK_IAM
sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required;
sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandlerConstraints:
Maximum 3000 TCP connections per broker with IAM. This limit is adjustable via
listener.name.client_iam.max.connectionsdynamic config.Maximum 100 new IAM connections per second per broker (M5/M7g); 4 per second on T3. This rate limit is not customer-adjustable.
SASL/SCRAM Authentication
security.protocol=SASL_SSL
sasl.mechanism=SCRAM-SHA-512
sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
username="<username>" password="<password>";Store credentials in AWS Secrets Manager. Associate the secret with the MSK cluster. This config format is required for the Kafka CLI (kafka-console-producer.sh, etc.). In application code, retrieve credentials from Secrets Manager at runtime and inject into the JAAS config programmatically — do not store passwords in source-controlled config files.
TLS (mTLS) Authentication
security.protocol=SSL
ssl.truststore.location=/path/to/truststore.jks
ssl.truststore.password=<password>
ssl.keystore.location=/path/to/keystore.jks
ssl.keystore.password=<password>
ssl.key.password=<password>This config format is required for the Kafka CLI. In application code, load keystore/truststore passwords from Secrets Manager or SSM Parameter Store (SecureString) at startup — do not commit passwords to source-controlled config files.
If you don't have an existing CA, AWS Private CA can issue and rotate client certificates for MSK mTLS.
References
Custom Domain Name Connectivity (NLB, certificate, DNS)
Custom domain names for MSK brokers are set with the custom.advertised.listeners cluster configuration property — see configure-cluster.md for that property, its validation rules, and the apply/rollback workflow. This section covers the client-facing networking and trust layer you own, which must be in place before that property is applied.
Because you cannot change the certificate MSK brokers present, custom domains are fronted by a Network Load Balancer (NLB). See Configure a custom domain name for your Amazon MSK cluster for the full walkthrough.
Prerequisite: build the networking/trust layer BEFORE the property is applied
The custom.advertised.listeners property only changes what brokers advertise. The client connectivity and trust layer is a prerequisite, not a follow-up — apply the property before it exists and you disconnect clients. Kafka clients do not keep using the address they bootstrapped with: on the next metadata refresh they learn the new advertised listener and use it for all subsequent connections, so if the custom domain isn't resolvable, reachable, and trusted, connected clients cannot reconnect.
Safe two-phase cutover (also how you migrate from Amazon DNS to a custom domain):
Build the networking path first — NLB, DNS (Route 53 private hosted zone), and TLS certificate — and point clients at the custom bootstrap endpoint while they still connect to brokers over the AWS-generated addresses.
Apply
custom.advertised.listeners(see configure-cluster.md). At the next metadata refresh clients pick up the custom domain and cut over automatically, with no restart.
TLS handshake and mTLS
The NLB is a Layer 4 load balancer with TLS listeners: it terminates the client's TLS connection (presenting the ACM certificate for your custom domain, which the client validates against the cert's CN/SAN), then opens a separate, independent TLS negotiation to the target broker. That is two TLS sessions, not one end-to-end session. Because TLS terminates at the NLB and is re-negotiated to the broker, a client certificate presented in the client->NLB handshake is NOT passed through to the broker — so MSK TLS mutual authentication (mTLS) does not work through this NLB-termination pattern. Use SASL/SCRAM or IAM instead; they authenticate above the TLS transport (SCRAM challenge / IAM SASL token) and work correctly through the NLB.
Certificate
Import a single certificate into ACM and associate it with every TLS listener on the NLB. Set CN = bootstrap.example.com (valid for the bootstrap address) and add SANs for each broker name (b-1.example.com, b-2.example.com, …). The DNS name a client connects with must match the CN or a SAN or the handshake fails hostname validation. Reference the returned CertificateArn on each listener with an ssl-policy. For a private/self-signed CA, clients must import the root and intermediate CA certificates into their trust store (ssl.truststore.location); with a public CA they are already in the default trust store.
Target groups
For an N-broker cluster create N+1 target groups: one bootstrap group containing all brokers, plus one per broker. Each uses protocol TLS, target-type ip, is associated with the MSK VPC, and its port is the broker authentication port — 9096 for SASL/SCRAM, 9098 for IAM (do NOT use a plaintext/TCP target group). Get broker IPs with aws kafka list-nodes (ClientVpcIpAddress), register each broker's IP into its own target group, and register all broker IPs into the bootstrap group.
Listeners
One TLS listener per target group; the client-facing ports (e.g., 9000 → bootstrap, 9001/9002/9003 → b-1/b-2/b-3) are distinct from the broker auth target port (9096/9098).
Cross-zone load balancing
Disabled by default on NLBs — each node only forwards to healthy targets in its own AZ, which drops connections (or causes noticeable connection delays as the client tries every IP Route 53 returns) when the healthy target is in another AZ. Enable it:
aws elbv2 modify-load-balancer-attributes --load-balancer-arn <arn> \
--attributes Key=load_balancing.cross_zone.enabled,Value=trueOptionally set dns_record.client_routing_policy=availability_zone_affinity to reduce cross-AZ data charges.
Networking does not auto-scale with brokers
When you add or replace brokers, MSK applies custom.advertised.listeners to the new broker automatically (see configure-cluster.md), but the networking layer does NOT auto-scale — add the corresponding NLB listener, target group, and DNS record for each new broker, matching the host:port pattern. Skip that and clients resolve the new broker's custom address but cannot reach it.
Reference ports
PLAINTEXT/CLIENT 9092, TLS/CLIENT_SECURE 9094, SASL/SCRAM/CLIENT_SASL_SCRAM 9096, IAM/CLIENT_IAM 9098 (public variants 9194/9196/9198).
References
Configure a custom domain name for your Amazon MSK cluster — NLB, Route 53, and ACM walkthrough
Amazon MSK simplifies configuring custom domain names — the
custom.advertised.listenersproperty (see configure-cluster.md)
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS
- Publisher
- AWS (Official)
- Source
- aws/agent-toolkit-for-aws · plugins/aws-data-analytics/skills/managing-amazon-msk · commit 0a218f8
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
- Also distributed in
- aws/agent-toolkit-for-aws
AutoGineer is not affiliated with or endorsed by AWS.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download managing-amazon-msk.zip