{"id":24267734,"url":"https://github.com/msmolens/compile-for-aws-lambda","last_synced_at":"2025-09-12T03:20:53.415Z","repository":{"id":89456171,"uuid":"265941838","full_name":"msmolens/compile-for-aws-lambda","owner":"msmolens","description":"Compile arbitrary executables for AWS Lambda","archived":false,"fork":false,"pushed_at":"2021-01-19T19:58:13.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-15T13:08:10.715Z","etag":null,"topics":["amazon-linux-2","aws-lambda","dockerfile"],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","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/msmolens.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,"publiccode":null,"codemeta":null}},"created_at":"2020-05-21T20:09:28.000Z","updated_at":"2023-07-24T13:05:07.000Z","dependencies_parsed_at":"2023-05-18T21:15:50.901Z","dependency_job_id":null,"html_url":"https://github.com/msmolens/compile-for-aws-lambda","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/msmolens%2Fcompile-for-aws-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmolens%2Fcompile-for-aws-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmolens%2Fcompile-for-aws-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msmolens%2Fcompile-for-aws-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msmolens","download_url":"https://codeload.github.com/msmolens/compile-for-aws-lambda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241955039,"owners_count":20048405,"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":["amazon-linux-2","aws-lambda","dockerfile"],"created_at":"2025-01-15T12:19:50.534Z","updated_at":"2025-03-05T02:43:19.115Z","avatar_url":"https://github.com/msmolens.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compile for AWS Lambda\n\n## Overview\n\nFor a native executable to run in an AWS Lambda function, it must be compatible\nwith the runtime's operating system. This repository is an example of using\nDocker to build a custom C++ executable that runs on AWS Lambda.\n\n## Requirements\n\n- [Docker](https://docs.docker.com/)\n- [Make](https://www.gnu.org/software/make/)\n\n## Usage\n\nEnter this directory and run `make`:\n\n```console\n$ cd /path/to/compile-for-aws-lambda\n$ make\n```\n\nThe `build` directory now contains binaries that can be packaged in the ZIP file\nfor an AWS Lambda function:\n\n```\n$ tree build\nbuild\n├── libsndfile.so -\u003e libsndfile.so.1\n├── libsndfile.so.1 -\u003e libsndfile.so.1.0.29\n├── libsndfile.so.1.0.29\n└── sine\n```\n\nThe example `sine` program generates a sine wave at the specified frequency (Hz)\nand writes it as a WAV file:\n```console\n$ cd build\n$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.\n$ ./sine 2600 /tmp/2600.wav\n$ file /tmp/2600.wav\n2600.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 24 bit, mono 44100 Hz\n```\n\nTo run the program in a Lambda function, use the\n[child_process](https://nodejs.org/docs/latest-v12.x/api/child_process.html)\nmodule in Node.js, or the\n[subprocess](https://docs.python.org/3.8/library/subprocess.html) module in\nPython.\n\n## Details\n\nFrom the [Running Arbitrary Executables in AWS\nLambda](https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/)\nblog post:\n\n\u003e If you compile your own binaries, ensure that they’re either statically linked\n\u003e or built for the matching version of Amazon Linux.\n\nThe example `sine` program in this repository uses the LGPL-licensed\n[libsndfile](https://github.com/erikd/libsndfile) library. To comply with the\nLPGL, libsndfile must be used as a shared library; it cannot be statically\nlinked.\n\n### Dockerfile\n\nTo compile binaries that are compatible with Amazon Linux 2, the\n[`Dockerfile`](./Dockerfile) starts from an Amazon Linux 2 base image:\n\n```docker\nFROM amazonlinux:2.0.20200406.0\n```\n\nThe Dockerfile then builds and installs `libsndfile` and `sine`. \n\nBinaries compiled in this environment will run on any AWS Lambda runtime that's\nbased on Amazon Linux 2, such as the Node.js 12 and Python 3.8 runtimes. See\n[AWS Lambda\nruntimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) for\na complete list.\n\n### Makefile\n\nThe [`Makefile`](./Makefile) creates a container from the Docker image and\ncopies the built artifacts from the container to the host system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmolens%2Fcompile-for-aws-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsmolens%2Fcompile-for-aws-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsmolens%2Fcompile-for-aws-lambda/lists"}