Provides a way of compiling ruby lambda code into a jruby executable (java runtime).
635
Run ruby code via JRuby on AWS Lambda (java)
This is a Dockerized gradle project for packaging a Ruby project into a zip file for execution in AWS Lambda using the Java 8 runtime.
my_ruby_lambda
Gemfile for any external libraries you are using
main.rb ruby file which will be the entrypoint for the lambda
BASE_DIRECTORY = File.realpath(File.dirname(__FILE__)).to_s
# Add current directory to the path
$LOAD_PATH.unshift BASE_DIRECTORY
# Require everything in lib
Dir["#{BASE_DIRECTORY}/lib/**/*.rb"].sort.each { |file| require file.sub("#{BASE_DIRECTORY}/", '').chomp('.rb') }
# rubocop:disable Style/GlobalVars
def main
MyRubyLambda::Lambda.new($lambda_arg).perform
rescue => e
puts "Lambda execution failed: Error #{e.inspect}\n#{e.backtrace.join("\n")}"
raise
end
# rubocop:enable Style/GlobalVars
# Only run the main function if the file has been called directly
main if $PROGRAM_NAME == __FILE__
|-- my_ruby_lambda
|-- Gemfile
|-- main.rb
|-- lib
|-- awesome_sauce.rb
|-- ...
app.zip in the project directory
docker run -v my_ruby_lambda:/usr/src/code firespring/aws-lambda-jrubyCreate an AWS Lambda fuction on AWS
Java 8Upload the lambda function code
.ZIP fileJava 8AWSLambdaJRuby::handlerUpload and select app.zipYou can now run your lambda
Content type
Image
Digest
Size
529.3 MB
Last updated
over 8 years ago
docker pull firespring/aws-lambda-jruby