Lenses MSK IAM Connection

My Kafka instance is hosted in MSK, and my authentication is configured using IAM. How can I utilize Lenses to connect to my MSK instance with IAM, considering that my Lenses instance is deployed on EC2?

You can set up Lenses with IAM in two ways. The first and simplest is to add the access and secret key pair to the AWS_ACCESS_KEY and AWS_SECRET_KEY environment variables, respectively.

The second way is to have an IAM role enabled on your EC2 host that allows you to interact with MSK. It’s more recommended to have IAM configured rather than the key pair, as it’s more secure.

Configuring it in Lenses is very simple, on the Kafka Broker configuration screen in Lenses, select the MSK IAM for the brokers. Check the SASL SSL option, and in the SASL Mechanism, select AWS_MSK_IAM.

You can also connect to the AWS Glue Schema Registry in a similar way.