I'm converting a legacy Serverless Framework app w...
# sst
s
I'm converting a legacy Serverless Framework app written in Python to SST. Things are going fairly smoothly, but my deployed lambdas are large (30+MB) due to bundled dependencies. I've successfully created lambda layers for some of the larger dependencies (psycopg2), but don't understand how to prevent them from being bundled with the deployed lambda. Any tips for how this can be achieved?
f
Hey @Seth Geoghegan, this is the docker image that bundles the lambda functions. And you can override the install commands by configuring the
bundle.installCommands
flag here.
And if you override the install commands, this docker image will be used.
And whatever gets generated here is bundled with your Lambda code.
So one way to achieve this is to customize the install commands to only install a subset of dependencies.
s
Oh, interesting. I hadn't seen this option
f
Yeah, lemme know if you have better ways to do this.
s
I'll see how far I get with this. I'm pretty new to the python ecosystem, but I have teammates that may have some ideas
f
yup, how SST bundles Python is similar to CDK’s aws-lambda-python https://docs.aws.amazon.com/cdk/api/v1/docs/aws-lambda-python-readme.html
s
huh, I didn't know there was such a construct!