{"id":13879516,"url":"https://github.com/aws-samples/serverless-sinatra-sample","last_synced_at":"2025-07-16T15:32:26.474Z","repository":{"id":34190493,"uuid":"157784012","full_name":"aws-samples/serverless-sinatra-sample","owner":"aws-samples","description":"Demo code for running Ruby Sinatra on AWS Lambda","archived":false,"fork":false,"pushed_at":"2022-06-25T20:21:31.000Z","size":62,"stargazers_count":213,"open_issues_count":0,"forks_count":62,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-08-07T08:12:46.729Z","etag":null,"topics":["api-gateway","aws-alb","aws-lambda","codepipeline","lambda","ruby","ruby-sinatra","serverless","serverless-examples"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aws-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-15T23:09:14.000Z","updated_at":"2024-04-11T17:47:19.000Z","dependencies_parsed_at":"2022-09-01T20:41:04.325Z","dependency_job_id":null,"html_url":"https://github.com/aws-samples/serverless-sinatra-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fserverless-sinatra-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fserverless-sinatra-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fserverless-sinatra-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aws-samples%2Fserverless-sinatra-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aws-samples","download_url":"https://codeload.github.com/aws-samples/serverless-sinatra-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-gateway","aws-alb","aws-lambda","codepipeline","lambda","ruby","ruby-sinatra","serverless","serverless-examples"],"created_at":"2024-08-06T08:02:23.552Z","updated_at":"2024-11-24T08:31:26.017Z","avatar_url":"https://github.com/aws-samples.png","language":"Ruby","readme":"## Running Ruby Sinatra on AWS Lambda\n\nThis 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. \n\nAdditional details can be found at: https://aws.amazon.com/blogs/compute/announcing-ruby-support-for-aws-lambda/\n\n__Other resources:__\n\nRuby Sinatra on AWS Lambda: https://blog.eq8.eu/article/sinatra-on-aws-lambda.html\n\nWe want FaaS for Ruby: https://www.serverless-ruby.org/\n\nWhat's Here\n-----------\n\nThis sample includes:\n\n* README.md - this file\n* Gemfile - Gem requirements for the sample application\n* app/config.ru - this file contains configuration for Rack middleware\n* app/server.rb - this file contains the code for the sample service\n* app/views - this directory has the template files\n* spec/ - this directory contains the RSpec unit tests for the sample application\n* template.yaml - this file contains the description of AWS resources used by AWS\n  CloudFormation to deploy your serverless application\n* 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\n* buildspec.yml - this file contains build commands used by AWS CodeBuild\n\nGetting Started\n---------------\n\nThese directions assume you already have Ruby 2.5.x and [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) installed and configured. Please fork the repo and create an [access token](https://github.com/settings/tokens/new) if you want to create a [CodePipeline](https://aws.amazon.com/codepipeline/) to deploy the app. The pipeline-cfn.yaml template can be used to automate the process.\n\nTo 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](https://help.github.com/articles/cloning-a-repository/).\n\n1. Ensure you are using ruby version 2.5.x\n\n2. Install bundle\n\n        $ gem install bundler -v \"~\u003e 1.17\"\n\n3. Install Ruby dependencies for this service\n\n        $ bundle install\n\n4. Download the Gems to the local vendor directory\n\n        $ bundle install --deployment\n\n5. Create the deployment package (note: if you don't have a S3 bucket, you need to create one):\n\n        $ aws cloudformation package \\\n            --template-file template.yaml \\\n            --output-template-file serverless-output.yaml \\\n            --s3-bucket { your-bucket-name }\n            \n    Alternatively, if you have [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) installed, you can run the following command \n    which will do the same\n\n        $ sam package \\\n            --template-file template.yaml \\\n            --output-template-file serverless-output.yaml \\\n            --s3-bucket { your-bucket-name }\n            \n6. Deploying your application\n\n        $ aws cloudformation deploy --template-file serverless-output.yaml \\\n            --stack-name { your-stack-name } \\\n            --capabilities CAPABILITY_IAM\n    \n    Or use SAM CLI\n\n        $ sam deploy \\\n            --template-file serverless-output.yaml \\\n            --stack-name { your-stack-name } \\\n            --capabilities CAPABILITY_IAM\n\n7. 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.\n\n__Note__:\nYou can also use an [Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/features/#Details_for_Elastic_Load_Balancing_Products) instead of API gateway. \nFor details, please visit https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html\n\nWhat Do I Do Next?\n------------------\n\nIf you have checked out a local copy of your repository you can start making changes to the sample code. \n\nLearn more about Serverless Application Model (SAM) and how it works here: https://github.com/awslabs/serverless-application-model/blob/master/HOWTO.md\n\nAWS Lambda Developer Guide: http://docs.aws.amazon.com/lambda/latest/dg/deploying-lambda-apps.html\n\nHow Do I Add Template Resources to My Project?\n------------------\n\nTo add AWS resources to your project, you'll need to edit the `template.yaml`\nfile in your project's repository. You may also need to modify permissions for\nyour project's IAM roles. After you push the template change, AWS CloudFormation provisions the resources for you.\n\n## License\n\nThis library is licensed under the Apache 2.0 License.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Fserverless-sinatra-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faws-samples%2Fserverless-sinatra-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faws-samples%2Fserverless-sinatra-sample/lists"}