1
0

More than 3 years have passed since last update.

pip installしたライブラリをLambda layerする

Posted at

lambda環境で実行するとpython3.8環境のsys.pathは以下でした。

[
  '/var/task', 
  '/opt/python/lib/python3.8/site-packages', 
  '/opt/python', // ここ
  '/var/runtime', 
  '/var/lang/lib/python38.zip', 
  '/var/lang/lib/python3.8', 
  '/var/lang/lib/python3.8/lib-dynload', 
  '/var/lang/lib/python3.8/site-packages', 
  '/opt/python/lib/python3.8/site-packages'
]

layerはopt以下に展開されるので、解凍して python/モジュール という構成になるzipを作ればよいです。
なので次のようにpythonディレクトリ以下にpipでライブラリをインストールすれば、layerで複数Lambda関数から利用できるようになります。

pip install pytz -t python

1
0
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
1
0