Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Latest commit

 

History

History
36 lines (26 loc) · 736 Bytes

File metadata and controls

36 lines (26 loc) · 736 Bytes

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.