Giter VIP home page Giter VIP logo

aws-lambda-container-julia's Introduction

aws-lambda-container-julia

As of December 2020, AWS supports running Lambda functions from any container image. This is an example of deploying Julia program as AWS lambda.

How it works

The Dockerfile uses an AWS provided base image. It is more convenient because their base image already includes the Runtime Interface Emulator (RIE). It would be possible to use a different base image but then the RIE has to be installed separately. Julia is downloaded and installed from the official julialang.org web site.

Project content are copied to the standard deployment directory /var/task. By setting JULIA_DEPOT_PATH environment variable, the precompiled files will be stored in a known location.

Note that AWS Lambda provides a read-only file system. If needed, the JULIA_DEPOT_PATH can be reset to include /tmp/.julia for additional precompilation during runtime. See AWS FAQ for container images for more information.

As required, Lambda functions must support the Lambda Runtime API. The main.jl file implements the general workflow of this API, which involves fetching lambda invocation requests, calling the handle_event function, and reporting results back to the Lambda execution environment. This runtime is normally provided by AWS for the officially supported languages. For Julia, we're just rolling our own.

This main program delegates lambda requests to the underlying module. In this case, it's called JuliaLambdaExample. The module must define a function called handle_event and the function must accept two arguments - event_data and headers. The return value of this function is then passed back to the lambda environment.

How to use this repo

To build your own AWS Lambda function, you can copy this repo and rename the JuliaLambdaExample to whatever you want. Just make sure that all references are renamed properly.

There is a convenient shell script in scripts/deploy.sh that can be used to quickly build/tag/push a Docker image and deploy the function on AWS.

For example:

sh scripts/deploy.sh julia-lambda latest

The script does not deploy the lambda function unless it is already created. Hence, just for the first time, you must create the lambda function using your preferred approach (web interface, cloud formation, CDK, etc.)

Contributions welcome!

Feel free to raise an issue or PR if you would like to contribute to this repo.

aws-lambda-container-julia's People

Contributors

tk3369 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.