claranet / terraform-aws-lambda

Terraform module for AWS Lambda functions
MIT License
157 stars 127 forks source link

Pass --python-version to pip install (along with --only-binary=:all:) #76

Open pdecat opened 3 years ago

pdecat commented 3 years ago

This allows to package dependencies like rtoml with compiled binaries when local python version differs from Lambda runtime python version.

Without this change with python 3.9 locally targetting python 3.8 Lambda runtime:

# unzip -t .terraform/modules/my.lambda-notify/builds/b002507ad36e4a2c5527e154c21d5e88215c4647ca39461c89a1031eddabc806.zip | grep rtoml.*.so
    testing: rtoml/_rtoml.cpython-39-x86_64-linux-gnu.so   OK

With this change:

unzip -t .terraform/modules/my.lambda-notify/builds/95f1ec0c95f09c8e5832de7d5ef605cf20be46d8015bfa704782e4f33f860d10.zip | grep rtoml.*.so
    testing: rtoml/_rtoml.cpython-38-x86_64-linux-gnu.so   OK

Related: https://github.com/claranet/terraform-aws-lambda/issues/23