Kafka MSK IAM integration

Installation

You need to have "kafkajs": "^2.2.0-beta.0" installed.

For more information look at tulios/kafkajs#840 (comment).

npm i @jm18457/kafkajs-msk-iam-authentication-mechanism 

Setup

const { Kafka } = require('kafkajs')
const {
  awsIamAuthenticator,
  Type
} = require('@jm18457/kafkajs-msk-iam-authentication-mechanism')

const kafka = new Kafka({
  brokers: process.env.BROKERS.split(','),
  clientId: 'consumer',
  ssl: true,
  sasl: {
    mechanism: Type,
    authenticationProvider: awsIamAuthenticator(process.env.REGION, process.env.TTL)
  }
})

Examples

For working examples look at example folder.