LoginSignup
17
12

More than 5 years have passed since last update.

Serverless Python Requirements で楽をする

Posted at

AWS Lambda で Python のモジュールを使うとき、Amazon Linuxでコンパイルしなくてはいけないモジュールを使うには、面倒な手順が必要だと思っていたのですが、もっとお手軽な方法がありました。serverless frameworkプラグイン を使います。

ほぼクラスメソッドさんの記事の通りなのですが、一部 yaml の書き方が異なっていました。

non-pure-Python モジュールをコンパイルする場合は、serverless.yml に以下の設定を追加します。

serverless.yml
plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: true

これだけ、実に楽チンです。

なお、requirements.py はどこにあるんだ? と思った方は、以下のコマンドを実行してみてください。

% sls requirements install
17
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
12