I am trying to deploy my lambda function that makes a requests and decrypts data using pycrypto's module Crypto.Cipher AES. This is how my import looks:
import boto3
from botocore.vendored import requests
import gzip
from io import StringIO, BytesIO
import base64
import sys
from datetime import datetime
import time
from Crypto.Cipher import AES
I run my code in my local Mac Environment and it works perfectly, but when I upload my package to AWS Lambda and test it, I get the following error:
Unable to import module 'lambda_function': cannot import name '_AES'
I checked this question and downloaded the pycrypto package from this git repo, made the build and copied the results to my lambda folder, packaged it and still didn't work.
I checked the result of the build and I noticed that within this folder:
pycrypto-2.6.1/build/lib.linux-x86_64-3.7/Crypto/Cipher
The AES files are generated with an extension related to my Mac OS
I tried building the package on a Linux EC2 instance, but still get the same error (although the files change)
I tried a new path based on the following question but still failed with the exact same error.
"errorMessage": "Unable to import module 'lambda_function'"
Why is AWS Lambda not able to read the AES module in the pycrypto package? I have deployed Lambda function with other external libraries and never faced this issue.