How to Create a AWS Lambda Layer of Your Gemfile / Ruby Gem Dependencies

If you use AWS SAM to build and deploy your serverless Ruby functions, it'll take care of building your dependencies on a function by function basis and package them up for deployment. Great!But if you don't want to use SAM, using gems with native dependencies (e.g. Nokogiri) is a nightmare! If you prefer to travel light (or, maybe, you like coding throwaway functions in the AWS console), you can instead build your dependencies into a Lambda Layer and then use that layer across whatever Lambda functions you like without worrying about dependencies again.But how? After an hour of trial and error plus a few tips from this neat article (though that one still used SAM), I figured out the magic spell required to locally build Ruby gems and their dependencies in a local Amazon Linux container and turn them into a layer.
How to Create a AWS Lambda Layer of Your Gemfile / Ruby Gem Dependencies #ruby #rubydeveloper #rubyonrails #aws #gemfile https://rubyonrails.ba/single/how-to-create-a-aws-lambda-layer-of-your-gemfile-ruby-gem-dependencies

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles