Access AWS MSK Kafka cluster with IAM authentication using Teleport VNET #49064
milos-teleport
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Goal
Access AWS MSK Kafka with VNET while leveraging AWS IAM Authentication for AWS MSK
Prerequisites
Notes
At the time of writing this, November 2024, VNET is only supported on macOS with support for Linux and Windows planned.
Overview
We will use Teleport's VNET feature to access an AWS MSK Kafka cluster.
This guide will cover the following:
Prepare VNET
Apply the above config
tctl create vnet-config.yaml
Prepare the EC2 Teleport agent instance
This EC2 instance must reside in a subnet which can reach the MSK Kafka endpoints
Create the token
After launching an EC2 Teleport agent instance, run this
We need to add all our AWS MSK Kafka brokers as "apps" definitions in Teleport.
To do this, add the following block to
/etc/teleport.yaml
. This was not doable with CLI becausepublic_addr
is not yet a parameter inteleport configure
Workstation
Your workstation AWS credentials need to have IAM access for AWS MSK. Refer to the permission documentation here
Reference: Video from AWS describing generic Kafka access using AWS IAM authentication
Install java-17 which is supported by Kafka 3.6.1
Grab Kafka 3.6.1 using this command:
# I did this in the homedir of ec2-user wget https://archive.apache.org/dist/kafka/3.6.1/kafka_2.13-3.6.1.tgz tar -xzf kafka_2.13-3.6.1.tgz
Get the aws-msk-iam-auth jar file from here. For example:
wget https://github.com/aws/aws-msk-iam-auth/releases/download/v2.2.0/aws-msk-iam-auth-2.2.0-all.jar # And then move the file to libs mv aws-msk-iam-auth-2.2.0-all.jar kafka_2.13-3.6.1/libs/
config.txt
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.IAMClientCallbackHandler
Connect to VNET
Commands
Create a topic
List topics
Start a consumer in a separate shell (remember to run the export commands)
Start a producer, and start typing and hitting ENTER to add messages to the Kafka topic.
Check back on the consumer. You should see the messages appear there.
Beta Was this translation helpful? Give feedback.
All reactions