'Error while using confluent-kafka python library with AWS lambda

I am trying to use the confluent-kafka python library to administer my cluster via a lambda function but the function fails with the error:

"Unable to import module 'Test': No module named 'confluent_kafka.cimpl'"

My requirements.txt

requests
confluent-kafka

To create the zip file I moved my code to the site-packages location of the virtual env and zipped everything.

Python Code:

import confluent_kafka.admin
import requests
def lambda_handler(event, context):
    print("Hello World")

I am using the macOS 10.X. On Linux, I noticed that pip install creates a separate confluent_kafka.libs which does not get created on mac



Solution 1:[1]

I hit this even after setting up a layer properly. I was able to work around this problem by setting my layer and function to use the architecture x86_64

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1