Skip to content

Best way of establishing authentication between AWS Lambda and MSK for producing messages

0

Data Flow Path: Multiple SQS Queues -> Lambda Instances -> MSK Topic Lambda and MSK are in same VPC/subnets. We need to finalise the best option for establishing/configuring the authentication between Lambda and MSK.

IAM Access Control: Easy option but there is a quota limit with this for MSK Maximum TCP Connections rate per broker(IAM) - 100. We feel this limitation will be hit as number of Lambda instances (producer side) initiating the connection request through IAM based authentication might cross 100 sometimes.

Other option is to use mTLS based authentication but wonder if there will be latency issues during the initial handshake.

1 Answer
0

Hi,

To handle authentication between AWS Lambda and MSK for producing messages, particularly when multiple SQS Queues trigger Lambda instances that need to produce to MSK topics, you have two options:

For IAM Access Control, while it's the simpler option to implement, there's a significant limitation: MSK has a quota of maximum 100 TCP connections per broker when using IAM authentication. This can become problematic when multiple Lambda instances (producer side) initiate connection requests, potentially exceeding this limit during high-load scenarios.

The alternative is mTLS-based authentication, which doesn't have the connection limit constraint but requires careful consideration of potential latency during the initial TLS handshake. However, this latency is typically minimal and can be mitigated through connection pooling strategies.

Given these considerations, here's the recommended approach: If your workload consistently requires more than 100 concurrent Lambda instances producing messages, use mTLS authentication with a connection pooling implementation. This provides better scalability and removes the IAM connection limit constraint. However, if your workload is smaller and you prefer easier implementation, IAM authentication is sufficient.

For either approach, ensure proper error handling and monitoring. With mTLS, implement certificate rotation and management procedures. With IAM, monitor connection counts and implement backoff strategies if approaching limits.

For implementation details, refer to:

AWS
answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.