claranet / terraform-aws-lambda

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

Question - How do you provide and use python requirements.txt #66

Open ryanash999 opened 4 years ago

ryanash999 commented 4 years ago

The documentation indicates that a requirements.txt can be used to automatically build with the necessary python modules. Where is requirements.txt placed? How is it referenced? Documentation could be expanded a bit for this portion.

Thanks

raymondbutcher commented 4 years ago

Hi.

Just to quickly answer your questions, this test:

https://github.com/claranet/terraform-aws-lambda/blob/f9ff6ee0788e187327c182f691041fbc9527e080/tests/python-versions/python3/main.tf#L23-L32

uses this directory for the source path:

https://github.com/claranet/terraform-aws-lambda/tree/master/tests/python-versions/lambda

And you can see that requirements.txt is just sitting in the top of source directory.

This module copies the source path into a temporary directory, runs pip install requirements.txt if the file exists, zips up the temporary directory, then uses that for the Lambda function package.

ryanash999 commented 4 years ago

Thanks!

raymondbutcher commented 4 years ago

Reopening so we don't forget to make this clearer in the readme.