RubyLambda
RubyLambda is a toolset for developing and deploying serverless Ruby apps in AWS Lambda.
Installation
$ gem install ruby_lambda
Usage
The main available commands.
$ ruby-lambda init
$ ruby-lambda execute
$ ruby-lambda build
$ ruby-lambda deploy
Commands
ruby-lambda init
$ ruby-lambda init
Initializes the .gitignore, config.yml, env, event.json, lambda_function.rb, Gemfile, .ruby-version files.
event.jsonis where you keep mock data that will be passed to your function when theexecutecommand has ran.config.ymlcontains some default configuration for your function.envwill be renamed to.envafter the init command runs, it will containAWS_ACCESS_KEYandAWS_SECRET_ACCESS_KEY. You will need these to be able to deploy your function.
Please have a read of the config.yml and update any of the default configuration to better suit your function.
ruby-lambda execute
$ ruby-lambda execute
This command is used to invoke / run the function locally
Options:
-c, [--config=CONFIG] # Default: config.yml
-H, [--handler=HANDLER]
Examples
$ ruby-lambda execute -c=config.yml$ ruby-lambda execute -H=lambda_function.handler
The handler function is the function AWS Lambda will invoke / run in response to an event. AWS Lambda uses the event argument to pass in event data to the handler. If the handler flas is passed with execute, this will take precedence over the handler function defined within the config.yml
def handler(event:, context:)
{ statusCode: 200, body: JSON.generate('Hello from Ruby Lambda') }
end
The execute command gets the values stored in the event.json file and passes them to your handler function.
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/cookieshq/ruby_lambda. This project is intended to be a welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the RubyLambda project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.