aws_lambda_runtime
Version, currently main branch1 version
- main branchlatestApr 2, 2021
github.com/lagr/aws_lambda_runtime
Crystal runtime for AWS Lambda
Installation
# Add this to your shard.yml
dependencies:
aws_lambda_runtime:
github: lagr/aws_lambda_runtime
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.0.0- License
- MIT
- Author
- Lars Greiving
Dependencies
This version declares no dependencies.
README
aws_lambda_runtime
An AWS Lambda runtime for crystal.
While this is a working implementation, it is not tested yet and the API is likely subject to change. Feel free to give it a try, nonetheless!
Installation
-
Add the dependency to your
shard.yml:dependencies: aws_lambda_runtime: github: lagr/aws_lambda_runtime -
Run
shards install
Usage
The basic usage which should be suitable for most use cases is as follows:
require "aws_lambda_runtime"
AwsLambdaRuntime.run do |event, invocation|
# do your thing
puts "event is a #{event.class.name}."
# => event is a JSON::Any.
# return something that responds to to_json
{ "serialize-this": "my friend" }
end
This will provide event as JSON::Any and invocation as AwsLambdaRuntime::Invocation to the block.
Advanced Usage
Passing a Proc, e.g. one derived from a method, permits to bypass the parsing of the event as JSON::Any:
def handler(event, invocation)
# do your thing
puts "event is a #{event.class.name}."
# => event is a JSON::Any.
# return something that responds to to_json
{ "serialize-this": "my friend" }
end
AwsLambdaRuntime.run(->handler(JSON::Any, AwsLambdaRuntime::Invocation))
Working on the raw String can be handy to define custom mappings for the expected event data or to defer parsing to a later point in time:
class SQSMessage
include JSON::Serializable
@[JSON::Field(key: "messageId")]
property message_id : String
property attributes : JSON::Any
end
class SQSEvent
include JSON::Serializable
@[JSON::Field(key: "Records")]
property messages : Array(SQSMessage)
end
def handler(event, invocation)
puts "event is a #{event.class.name}."
sqs_event = SQSEvent.from_json(event)
{ "first-message-attributes": sqs_event.messages.first.attributes }
end
AwsLambdaRuntime.run(->handler(String, AwsLambdaRuntime::Invocation))
Development
TODO: :-)
Notable Mentions
This shard is inspired by crambda.
Contributing
- Fork it (https://github.com/lagr/aws_lambda_runtime/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Lars Greiving - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Apr 2, 2021
- Crystal
1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/lagr/aws_lambda_runtime
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 14, 2026
- Versions
- 1