Building AWS Lambdas for Real World using Ruby and Serverless Framework

Jalerson Lima on December 09, 2018

You may be wondering: "Why AWS Lambdas for Real World?". Well, since Amazon announced Ruby support for AWS Lambdas on November 29th, I've been read... [Read Full]
markdown guide

I just published a serverless plugin to handle a lot of this

The are a couple modifications from the approach you describe. First, the plugin excludes all files by default, so you need to whitelist (add to the package/includes section) any files or directories you want to package.
Second, I recommend bundle install --standalone --path vendor/bundle instead of messing with bundle install --deployment. As you discovered, the "deployment" mode is really only intended for deployment, not active development, so you always need to immediately undo it. Instead, "standalone" accomplishes the part we actually care about, specifically, it copies all of the gem files into the vendor directory in your working directory. The plugin then analyzes your Gemfile to figure out which gems should be included, or excluded if they are in the development/test groups.


I've managed my deployment pipeline in a different way, using the serverless-hooks-plugin and adding the following to the serverless.yml:

  - serverless-hooks-plugin

      - bundle install --path vendor/bundle --without test development --clean
      - rm -rf ./vendor/bundle/ruby/2.5.0/cache

      - bundle install --path vendor/bundle --with test development --clean

Great article Jalerson ! I published an article on the same topic this morning :


This is great! Thanks so much for the overview of the process and pitfalls; can't wait to try this out.


Auto-bookmark! Can't wait to see more of what Rubyists do with Lambda.


Did you manage to install gems that have native bindings (such as mysql2) successfully?


This is super helpful! I am having issues with conflicting gems already installed on lambda and being preferred (specifically, JSON 2.1.0 is too new). Did you find anything like that?

code of conduct - report abuse