{"id":14069519,"url":"https://github.com/numeract/aws-lambda-r","last_synced_at":"2026-05-28T19:30:40.840Z","repository":{"id":93562387,"uuid":"105833157","full_name":"numeract/aws-lambda-r","owner":"numeract","description":"Using R on AWS Lambda","archived":false,"fork":false,"pushed_at":"2021-04-14T11:16:31.000Z","size":2617,"stargazers_count":49,"open_issues_count":10,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-30T05:54:30.694Z","etag":null,"topics":["api-gateway","aws","aws-cli","aws-lambda","faas","r","serverless"],"latest_commit_sha":null,"homepage":"https://numeract.github.io/aws-lambda-r/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/numeract.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-10-05T00:22:05.000Z","updated_at":"2025-07-15T13:33:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f57d8ef-0892-4c4f-b144-8a79143d088f","html_url":"https://github.com/numeract/aws-lambda-r","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/numeract/aws-lambda-r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numeract%2Faws-lambda-r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numeract%2Faws-lambda-r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numeract%2Faws-lambda-r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numeract%2Faws-lambda-r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/numeract","download_url":"https://codeload.github.com/numeract/aws-lambda-r/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/numeract%2Faws-lambda-r/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33624202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","aws-cli","aws-lambda","faas","r","serverless"],"created_at":"2024-08-13T07:07:00.942Z","updated_at":"2026-05-28T19:30:40.822Z","avatar_url":"https://github.com/numeract.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Using R on AWS Lambda\n\n\n### Summary\n\nThis repo contains several scripts that facilitate execution of R functions on \nAWS Lambda.\n\nCurrently (March 2018) it is not possible to run R code directly on AWS Lambda,\nthus we need to invoke it through Python.\n\nThe scripts:\n\n- use your settings to create an AWS EC2 instance, \n- install and compile R packages\n- create the zip file to load in AWS Lambda and save it to S3\n- create Lambda function and deploy the zip file\n- configure AWS API Gateway to allow accessing the code over the web\n\nAt the end of the setup, you will have a AWS Lambda function that can be invoked\nas many times as you wish trough AWS API Gateway, without worrying about EC2 instances or scalability issues.\n\n\n### Scope\n\nThe best use case of this setup is \n\n- almost unlimited scalability (1000 concurrent executions)\n- no idle server time \n- very low cost\n- R functions are small and execute fast\n- input and output through JSON strings\n\n\n### Limitations\n\nAWS Lambda and API Gateway impose several limitations\n\n- maximum memory 3008MB \n    + this should be sufficient to run most functions\n- maximum zip file size 250MB \n    + this is the most important limitation as it prevents using large R packages\n- maximum execution time 30 seconds for API Gateway, 5 minutes for AWS Lambda\n    + be sure to take allow 1-2 sec for start time\n\n\n### Description\n\n**The current setup assumes that the following directories and their content\nwill be added to your R project directory.**\n\n- `lambda/` : a temporary directory with files to be uploaded\n- `python/` : contains Python files, one for each AWS Lambda entry point, \nthat will be used to invoke the R code\n- `scripts/` : the scripts compiling R packages and deploying to AWS Lambda\n- `settings/` : settings files used for deployment (e.g. where to find AWS settings)\n\nDirectory `doc/` contains additional documentation about how to setup for your \nAWS account (although familiarity with AWS helps a lot) and how to delete the \nsetup created by these scripts.\n\n\n### Installation and configuration\n\n1. Install [AWS CLI](https://aws.amazon.com/cli/) on your local machine\n    + Be sure that you stored your credentials in `~/.aws/` directory\n    + Optionally, create a profile for AWS CLI with [aws configure --profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)\n    + Check that you can connect to your AWS account using the desired profile\n        + `aws sts get-caller-identity --profile aws-lambda-r`\n2. Prepare your project\n    + Ideally, the project directory name should contain only letters, dashes, and digits, e.g. `aws-lambda-r`\n    + Be sure that git is initialized in the project directory (without git it \n    will be almost impossible to keep track of changes, especially in production)\n        + `git status`\n3. Copy directories `lambda/`, `python/`, `scripts/`, `settings/` to your project directory\n4. Copy and rename `setup_auto_example.sh` and `setup_user_example.sh` to \n`setup_auto.sh` and `setup_user.sh` \n5. Overwrite variables from `secrets_default.sh` and `setup_default` with \npersonal secrets in `setup_user.sh`. Variables such as `PRJ_NAME`, `PRJ_BRANCH`, \n`AWS_REGION` and `EC2_DEFAULT_AMI_ID` from `settings_default.sh` \nshould be overwritten accordingly in `setup_user.sh`.\n6. For automated AWS infrastructure setup run first `21_setup_vpc.sh`, \n`22_setup_custom_ami.sh`, `23_setup_s3.sh` and `24_setup_lambda.sh`, \notherwise create the infrastructure manually, following the documentation.\n\n\n###  macOS additional steps\n\nInstall the following packages, if not already installed:\n\n1. [**Homebrew**](https://brew.sh)\n\n`$ ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"`\n\n2. [**Bash 4**](http://tldp.org/LDP/abs/html/bashver4.html)\n\n`$ brew update \u0026\u0026 brew install bash`\n\n3. Add **Bash 4** as the default shell:\n\n```\n$ sudo nano /etc/shells\n\n# add to last line\n/usr/local/bin/bash\n\n# save and quit via ctrl + x\n```\n\n4. **md5sum**:\n\n`$ brew install md5sha1sum`\n\nLoad all the scripts via `sudo bash ./scripts/\u003cscript_name\u003e.sh` instead of \n`.scripts/\u003cscript_name\u003e.sh`.\n\n\n### References\n\n- [Analyzing Genomics Data at Scale using R, AWS Lambda, and Amazon API Gateway](https://aws.amazon.com/blogs/compute/analyzing-genomics-data-at-scale-using-r-aws-lambda-and-amazon-api-gateway/)\n- [Running R on AWS](https://aws.amazon.com/blogs/big-data/running-r-on-aws/)\n- [Lambda Execution Environment and Available Libraries](https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html)\n- [AWS Lambda limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html)\n\n\n### TODO\n\n- use AWS Cloud​Formation to create a template for all AWS config\n    + see \"Running R on AWS\"\n- script to check AWS CLI is properly installed\n- convert to an R package and execute the scripts from R\n- use `/tmp` folder on AWS Lambda to load large libraries (e.g., `BH`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumeract%2Faws-lambda-r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnumeract%2Faws-lambda-r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnumeract%2Faws-lambda-r/lists"}