serverless-python-requirements
serverless-python-requirements copied to clipboard
slimPatterns with botocore
I'm trying to tell SLSPR to not package up parts of botocore because I don't need to make calls to the services. I tried:
pythonRequirements:
dockerizePip: false
slim: true
slimPatterns:
# we don't need to call these services so let's not include the botocore metadata
# it takes up a lot of space
- "**/botocore/data/ec2/**"
- "data/cloudfront/**"
- "**/data/rds/**"
But ec2, cloudfront, and rds are all present in the package. What am I doing wrong? Using latest plugin/serverless.
Yeah, unfortunately, file globs in SPR are as horribly broken as every other tool I've seen that uses globs. I always have to hunt down the code running the glob and put print statements in.
Looking at my slim patterns file... You should drop the trailing /** because it will match directories correctly.
You shouldn't need to match **/botocore either, botocore should be at the root of your package. My slim patterns simply have entires like:
- botocore/data/ec2
**/*.ext works, though, as does path/*/dir.
(FWIW, I stuck them in a separate file because I banned a ton of crap. A lot of python modules carry tests with them, for instance.)
I have exactly this
pythonRequirements:
dockerizePip: false
slim: true
slimPatterns:
- botocore/data/ec2
- botocore/data/cloudfront
- botocore/data/rds
- botocore/data/iam
- botocore/data/s3
but I still see all of them except ec2 in the package :(
This also wasn't working for me until I added useStaticCache: false so that the dependencies could be rebuilt:
pythonRequirements:
useStaticCache: false
dockerizePip: true
slim: true
slimPatterns:
- botocore/data/ec2