connect to mariadb using aws lambda function

Viewed 19

I have a layer where I have installed mariadb and requests. The layer file is a zip archive of python\lib\python3.9\site-packages. Inside the site-packages, it looks like:

├── bin
├── certifi
├── certifi-2022.6.15.2.dist-info
├── charset_normalizer
├── charset_normalizer-2.1.1.dist-info
├── google
├── idna
├── idna-3.3.dist-info
├── mariadb
├── mariadb-1.1.4.dist-info
├── protobuf-3.20.1.dist-info
├── protobuf-3.20.1-py3.10-nspkg.pth
├── requests
├── requests-2.28.1.dist-info
├── urllib3
└── urllib3-1.26.12.dist-info

The AWS lambda function for now only has following code:

import requests
from mariadb import connect

When I test it, I get the following error

{
  "errorMessage": "Unable to import module 'lambda_function': No module named 'mariadb._mariadb'",
  "errorType": "Runtime.ImportModuleError",
  "requestId": "########",
  "stackTrace": []
}

How do I resolve this issue?

0 Answers
Related