How to add python libraries to lambda using the CDK?

0

I want to use a library in my lambda function that was created by the CDK.

I did the following, without success:

  1. add the library to my requirements.txt file

    Pillow

  2. import the library in my lambda function

    from PIL import Image

  3. install it and deploy

    source .env/bin/activate pip install -r requirements.txt cdk deploy`

Many thanks for any hints!

AWS
質問済み 3年前6889ビュー
1回答
0
承認された回答

You should have a look at the aws-lambda-python module: https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-python-readme.html

It's still experimental and needs docker, but it will take care of your requirements.txt.

The same exists for nodejs just in case (https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-nodejs-readme.html).

profile pictureAWS
回答済み 3年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ