Solution for aws lambda ModuleNotFoundError: No module named * for example 'pycares._cares'
docker run -v "$PWD":/var/task "public.ecr.aws/sam/build-python3.8" /bin/sh -c "pip install -r requirements.txt -t python/lib/python3.8/site-packages/; exit"
zip -r sd-scan-lib-layer.zip python > /dev/null
Change python3.8 to your lambda enviroment python version you can find all aws lambda enviroment docker images here This example is for pycares only, but you can change requirements.txt and rebuild the later for any python library or separate all the dependencies into one layer.
How do I create a Lambda layer