If you receive the following error message when trying to run
pymysql on AWS Lambda:
Unable to import module "lambda_function": No module named "pymysql" then you can fix this by running a Custom Lambda Layer.
To do this, you can boot up an EC2 instance (or a Linux instance anywhere else) and run the following set of commands:
Once this is done, you will be able to head back to AWS Lambda, click on
Layers and view your custom layer waiting there for you to use!
Now you can associate your lambda function to use this custom lambda layer.