How can I get my AWS Lambda to access gems stored in vendor/bundle?

前端 未结 3 500
青春惊慌失措
青春惊慌失措 2020-12-31 08:58

I\'m writing a Lambda function in Ruby which will eventually send me some notifications in Slack via Webhook. So what I have for my lambda_function file is

3条回答
  •  执念已碎
    2020-12-31 09:28

    I think you should not change the GEM_PATH or having to set $LOAD_PATH in every lambda functions. The "best" way is to do this little hack when you create the layer archive:

    bundle install --path vendor/bundle
    cd vendor/bundle
    mkdir ruby/gems
    mv ruby/2.5.0 ruby/gems/
    zip -r layer.zip ruby/gems/2.5.0/
    

提交回复
热议问题