Ryan Barnes
04/25/2022, 7:26 PMRuntime.ImportModuleError: Unable to import module 'handlers/alerts/demo_read_db': No module named 'marshmallow'
and I'm thinking this is bundling issue.
I notice that the actual deployed lambda function isn't running a docker container.
This is my cron job def
this.cron = new sst.Cron(this, 'cron', {
schedule: Duration.minutes(1),
job: {
// check the docs here to see what you can pass into the function props
// <https://docs.serverless-stack.com/constructs/Function>
function: {
runtime: 'python3.9',
srcPath: 'src',
handler: 'handlers/alerts/demo_read_db.handler',
bundle: {
installCommands: [
'yum -y install mariadb-devel gcc',
'pip install -r requirements.txt',
],
},
},
},
});
This is my requirements file that defines marshmallow
sqlalchemy-aurora-data-api==0.4.0
SQLAlchemy==1.4.23
flask-sqlalchemy
marshmallow==3.13.0
marshmallow-sqlalchemy==0.26.1
mysqlclient==2.0.3
When I run npx sst deploy --stage prod
I see on the cli that docker is building a container, yum installs packages, and pip installs packages
(snippet in thread). However when I go into the aws console and look at the code I just see bare code source (screenshot) and I notice that the package source is via zip. The lambda doesn't seem to have any access to the packages that are installed in the requirements file.
Any ideas?Ryan Barnes
04/25/2022, 7:40 PMRyan Barnes
04/25/2022, 9:45 PMRyan Barnes
04/25/2022, 10:22 PM'pip install -r requirements.txt -t .',
wasn't installing packages to the right location.Frank
sst deploy
, they are built in a Lambda-like docker environment.Frank
Frank
Ryan Barnes
04/27/2022, 9:18 PMRyan Barnes
04/27/2022, 9:18 PM