All Projects → aws-samples → Serverless Sinatra Sample

aws-samples / Serverless Sinatra Sample

Licence: apache-2.0
Demo code for running Ruby Sinatra on AWS Lambda

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Serverless Sinatra Sample

Aegis
Serverless Golang deploy tool and framework for AWS Lambda
Stars: ✭ 277 (+42.05%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Serverless Express
Run Node.js web applications and APIs using existing application frameworks on AWS #serverless technologies such as Lambda, API Gateway, Lambda@Edge, and ALB.
Stars: ✭ 4,265 (+2087.18%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Zappa
Serverless Python
Stars: ✭ 224 (+14.87%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+143.59%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Serverless Next.js
⚡ Deploy your Next.js apps on AWS Lambda@Edge via Serverless Components
Stars: ✭ 2,977 (+1426.67%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Zappa
Serverless Python
Stars: ✭ 11,859 (+5981.54%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Vandium Node
AWS Lambda framework for building functions using Node.js for API Gateway, IoT applications, and other AWS events.
Stars: ✭ 377 (+93.33%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Corgi
AWS Lambda / API Gateway native, fast and simple web framework
Stars: ✭ 44 (-77.44%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-73.85%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+4227.69%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (-47.69%)
Mutual labels:  api-gateway, serverless, aws-lambda, lambda
Hexaville
The modern serverless web application engine and framework for Swift
Stars: ✭ 123 (-36.92%)
Mutual labels:  api-gateway, serverless, lambda
Laravel Bridge
Package to use Laravel on AWS Lambda with Bref
Stars: ✭ 168 (-13.85%)
Mutual labels:  serverless, aws-lambda, lambda
Bref
Serverless PHP on AWS Lambda
Stars: ✭ 2,382 (+1121.54%)
Mutual labels:  serverless, aws-lambda, lambda
Serverless Aws Alias
Alias support for Serverless 1.x
Stars: ✭ 171 (-12.31%)
Mutual labels:  api-gateway, serverless, aws-lambda
Serverless Architectures Aws
The code repository for the Serverless Architectures on AWS book
Stars: ✭ 120 (-38.46%)
Mutual labels:  api-gateway, serverless, aws-lambda
Iopipe Js Core
Observe and develop serverless apps with confidence on AWS Lambda with Tracing, Metrics, Profiling, Monitoring, and more.
Stars: ✭ 123 (-36.92%)
Mutual labels:  serverless, aws-lambda, lambda
Es2017 Lambda Boilerplate
AWS Lambda boilerplate for Node.js 6.10, adding ES2018/7/6 features, Docker-based unit testing and various CI/CD configurations
Stars: ✭ 169 (-13.33%)
Mutual labels:  serverless, aws-lambda, lambda
Spark On Lambda
Apache Spark on AWS Lambda
Stars: ✭ 137 (-29.74%)
Mutual labels:  serverless, aws-lambda, lambda
Flogo
Project Flogo is an open source ecosystem of opinionated event-driven capabilities to simplify building efficient & modern serverless functions, microservices & edge apps.
Stars: ✭ 1,891 (+869.74%)
Mutual labels:  serverless, aws-lambda, lambda

Running Ruby Sinatra on AWS Lambda

This sample code helps get you started with a simple Sinatra web app deployed on AWS Lambda. It is tested with Ruby 2.5.x and bundler-1.17.x.

Additional details can be found at: https://aws.amazon.com/blogs/compute/announcing-ruby-support-for-aws-lambda/

Other resources:

Ruby Sinatra on AWS Lambda: https://blog.eq8.eu/article/sinatra-on-aws-lambda.html

We want FaaS for Ruby: https://www.serverless-ruby.org/

What's Here

This sample includes:

  • README.md - this file
  • Gemfile - Gem requirements for the sample application
  • app/config.ru - this file contains configuration for Rack middleware
  • app/server.rb - this file contains the code for the sample service
  • app/views - this directory has the template files
  • spec/ - this directory contains the RSpec unit tests for the sample application
  • template.yaml - this file contains the description of AWS resources used by AWS CloudFormation to deploy your serverless application
  • pipeline-cfn.yaml - this is the CloudFormation template to create the CodePipeline and the other needed resources. You need to fork the repo if you use a personal GitHub token
  • buildspec.yml - this file contains build commands used by AWS CodeBuild

Getting Started

These directions assume you already have Ruby 2.5.x and AWS CLI installed and configured. Please fork the repo and create an access token if you want to create a CodePipeline to deploy the app. The pipeline-cfn.yaml template can be used to automate the process.

To work on the sample code, you'll need to clone your project's repository to your local computer. If you haven't, do that first. You can find a guide here.

  1. Ensure you are using ruby version 2.5.x

  2. Install bundle

     $ gem install bundler -v "~> 1.17"
    
  3. Install Ruby dependencies for this service

     $ bundle install
    
  4. Download the Gems to the local vendor directory

     $ bundle install --deployment
    
  5. Create the deployment package (note: if you don't have a S3 bucket, you need to create one):

     $ aws cloudformation package \
         --template-file template.yaml \
         --output-template-file serverless-output.yaml \
         --s3-bucket { your-bucket-name }
    

    Alternatively, if you have SAM CLI installed, you can run the following command which will do the same

     $ sam package \
         --template-file template.yaml \
         --output-template-file serverless-output.yaml \
         --s3-bucket { your-bucket-name }
    
  6. Deploying your application

     $ aws cloudformation deploy --template-file serverless-output.yaml \
         --stack-name { your-stack-name } \
         --capabilities CAPABILITY_IAM
    

    Or use SAM CLI

     $ sam deploy \
         --template-file serverless-output.yaml \
         --stack-name { your-stack-name } \
         --capabilities CAPABILITY_IAM
    
  7. Once the deployment is complete, you can find the application endpoint from the CloudFormation outputs tab. Alternatively, you can find it under the Stages link from the API gateway console.

Note: You can also use an Application Load Balancer instead of API gateway. For details, please visit https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html

What Do I Do Next?

If you have checked out a local copy of your repository you can start making changes to the sample code.

Learn more about Serverless Application Model (SAM) and how it works here: https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md

AWS Lambda Developer Guide: http://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html

How Do I Add Template Resources to My Project?

To add AWS resources to your project, you'll need to edit the template.yaml file in your project's repository. You may also need to modify permissions for your project's IAM roles. After you push the template change, AWS CloudFormation provisions the resources for you.

License

This library is licensed under the Apache 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].