How to make a requirements.txt file per function in Serverless framework?

Hi,

In my Serverless application i have 2 Lambda Python functions and each one has some package requirements. I followed this article https://serverless.com/blog/flask-python-rest-api-serverless-lambda-dynamodb/#using-the-quick-start-template to create the requirements.txt file.

However in deployment i ended with the 2 functions having the packages listed in requirements.txt while only one should have them.

This is the structure of the app :

- my-app
  - node_modules
  - venv
  - function1
  .handler.py
  - function2
  .handler.py
  .serverless.yml
  .requirements.txt
  .package.json
  .package-lock.json

How to manage to make requirements.txt only be applied to 1 function and not the other one ?

Thanks.

You should use module and put requirement.txt to function folder that needed it.
example if function1 needs requirement

function1:
   module: function1