{"id":15626176,"url":"https://github.com/raysrashmi/photo-detection","last_synced_at":"2025-03-29T17:22:39.501Z","repository":{"id":38295427,"uuid":"195175683","full_name":"raysrashmi/photo-detection","owner":"raysrashmi","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-07T21:26:08.000Z","size":1495,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T18:24:50.479Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raysrashmi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-04T05:41:23.000Z","updated_at":"2019-07-04T12:15:45.000Z","dependencies_parsed_at":"2022-09-08T08:50:38.574Z","dependency_job_id":null,"html_url":"https://github.com/raysrashmi/photo-detection","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/raysrashmi%2Fphoto-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raysrashmi%2Fphoto-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raysrashmi%2Fphoto-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raysrashmi%2Fphoto-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raysrashmi","download_url":"https://codeload.github.com/raysrashmi/photo-detection/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246216674,"owners_count":20742039,"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":[],"created_at":"2024-10-03T10:11:08.675Z","updated_at":"2025-03-29T17:22:39.479Z","avatar_url":"https://github.com/raysrashmi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws_sam_ocr_ruby\n\nThis is a sample template for aws_sam_ocr_ruby - Below is a brief explanation of what we have generated for you:\n\n```bash\n.\n├── README.md                   \u003c-- This instructions file\n├── event.json                  \u003c-- API Gateway Proxy Integration event payload\n├── hello_world                 \u003c-- Source code for a lambda function\n│   ├── app.rb                  \u003c-- Lambda function code\n│   ├── Gemfile                 \u003c-- Ruby function dependencies\n├── template.yaml               \u003c-- SAM template\n├── Gemfile                     \u003c-- Ruby test/documentation dependencies\n└── tests                       \u003c-- Unit tests\n    └── unit\n        └── test_handler.rb\n```\n\n## Requirements\n\n* AWS CLI already configured with at Administrator permission\n* [Ruby 2.5 installed](https://www.ruby-lang.org/en/documentation/installation/)\n* [Docker installed](https://www.docker.com/community-edition)\n\n## Setup process\n\n### Local development\n\n**Invoking function locally using a local sample payload**\n\n```bash\nsam local invoke HelloWorldFunction --event event.json\n```\n\n**Invoking function locally through local API Gateway**\n\n```bash\nsam local start-api\n```\n\nIf the previous command ran successfully you should now be able to hit the following local endpoint to invoke your function `http://localhost:3000/hello`\n\n**SAM CLI** is used to emulate both Lambda and API Gateway locally and uses our `template.yaml` to understand how to bootstrap this environment (runtime, where the source code is, etc.) - The following excerpt is what the CLI will read in order to initialize an API and its routes:\n\n```yaml\n...\nEvents:\n    HelloWorld:\n        Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api\n        Properties:\n            Path: /hello\n            Method: get\n```\n\n## Packaging and deployment\n\nAWS Lambda Ruby runtime requires a flat folder with all dependencies including the application. SAM will use `CodeUri` property to know where to look up for both application and dependencies:\n\n```yaml\n...\n    HelloWorldFunction:\n        Type: AWS::Serverless::Function\n        Properties:\n            CodeUri: hello_world/\n            ...\n```\n\nFirstly, we need a `S3 bucket` where we can upload our Lambda functions packaged as ZIP before we deploy anything - If you don't have a S3 bucket to store code artifacts then this is a good time to create one:\n\n```bash\naws s3 mb s3://BUCKET_NAME\n```\n\nNext, run the following command to package our Lambda function to S3:\n\n```bash\nsam package \\\n    --output-template-file packaged.yaml \\\n    --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME\n```\n\nNext, the following command will create a Cloudformation Stack and deploy your SAM resources.\n\n```bash\nsam deploy \\\n    --template-file packaged.yaml \\\n    --stack-name aws_sam_ocr_ruby \\\n    --capabilities CAPABILITY_IAM\n```\n\n\u003e **See [Serverless Application Model (SAM) HOWTO Guide](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-quick-start.html) for more details in how to get started.**\n\nAfter deployment is complete you can run the following command to retrieve the API Gateway Endpoint URL:\n\n```bash\naws cloudformation describe-stacks \\\n    --stack-name aws_sam_ocr_ruby \\\n    --query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \\\n    --output table\n``` \n\n## Fetch, tail, and filter Lambda function logs\n\nTo simplify troubleshooting, SAM CLI has a command called sam logs. sam logs lets you fetch logs generated by your Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.\n\n`NOTE`: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.\n\n```bash\nsam logs -n HelloWorldFunction --stack-name aws_sam_ocr_ruby --tail\n```\n\nYou can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).\n\n## Testing\n\nRun our initial unit tests:\n\n```bash\nruby tests/unit/test_handler.rb\n```\n\n## Cleanup\n\nIn order to delete our Serverless Application recently deployed you can use the following AWS CLI Command:\n\n```bash\naws cloudformation delete-stack --stack-name aws_sam_ocr_ruby\n```\n\n## Bringing to the next level\n\nHere are a few things you can try to get more acquainted with building serverless applications using SAM:\n\n### Learn how SAM Build can help you with dependencies\n\n* Uncomment lines on `app.rb`\n* Build the project with ``sam build --use-container``\n* Invoke with ``sam local invoke HelloWorldFunction --event event.json``\n* Update tests\n\n### Create an additional API resource\n\n* Create a catch all resource (e.g. /hello/{proxy+}) and return the name requested through this new path\n* Update tests\n\n### Step-through debugging\n\n* **[Enable step-through debugging docs for supported runtimes]((https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging.html))**\n\nNext, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: [AWS Serverless Application Repository main page](https://aws.amazon.com/serverless/serverlessrepo/)\n\n\n# Appendix\n\n## Building the project\n\n[AWS Lambda requires a flat folder](https://docs.aws.amazon.com/lambda/latest/dg/ruby-package.html) with the application as well as its dependencies. When you make changes to your source code or dependency manifest,\nrun the following command to build your project local testing and deployment:\n\n```bash\nsam build\n```\n\nIf your dependencies contain native modules that need to be compiled specifically for the operating system running on AWS Lambda, use this command to build inside a Lambda-like Docker container instead:\n```bash\nsam build --use-container\n```\n\nBy default, this command writes built artifacts to `.aws-sam/build` folder.\n\n\n## SAM and AWS CLI commands\n\nAll commands used throughout this document\n\n```bash\n# Generate event.json via generate-event command\nsam local generate-event apigateway aws-proxy \u003e event.json\n\n# Invoke function locally with event.json as an input\nsam local invoke HelloWorldFunction --event event.json\n\n# Run API Gateway locally\nsam local start-api\n\n# Create S3 bucket\naws s3 mb s3://BUCKET_NAME\n\n# Package Lambda function defined locally and upload to S3 as an artifact\nsam package \\\n    --output-template-file packaged.yaml \\\n    --s3-bucket REPLACE_THIS_WITH_YOUR_S3_BUCKET_NAME\n\n# Deploy SAM template as a CloudFormation stack\nsam deploy \\\n    --template-file packaged.yaml \\\n    --stack-name aws_sam_ocr_ruby \\\n    --capabilities CAPABILITY_IAM\n\n# Describe Output section of CloudFormation stack previously created\naws cloudformation describe-stacks \\\n    --stack-name aws_sam_ocr_ruby \\\n    --query 'Stacks[].Outputs[?OutputKey==`HelloWorldApi`]' \\\n    --output table\n\n# Tail Lambda function Logs using Logical name defined in SAM Template\nsam logs -n HelloWorldFunction --stack-name aws_sam_ocr_ruby --tail\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraysrashmi%2Fphoto-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraysrashmi%2Fphoto-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraysrashmi%2Fphoto-detection/lists"}