Giter Site home page Giter Site logo

aripalo / lambda-container-image-with-custom-runtime-example Goto Github PK

View Code? Open in Web Editor NEW
15.0 4.0 6.0 1 KB

This is a brief example how to define a Lambda function with bash using Amazon Linux 2 based Custom Runtime and Container Image Support

Home Page: https://aripalo.com/blog/2020/aws-lambda-container-image-support/

Dockerfile 17.92% Shell 82.08%

lambda-container-image-with-custom-runtime-example's Introduction

Lambda Container Image Support (with Custom Runtime)

This is a brief example how to define a Lambda function with bash using Amazon Linux 2 based Custom Runtime and Container Image Support (relesed in re:Invent 2020).

See the blog post for more information: aripalo.com/blog/2020/aws-lambda-container-image-support/

Usage

(Very briefly, again see the blog post for more.)

Local testing

cd src

docker build -t lambda-container-demo .
docker run -p 9000:8080 lambda-container-demo:latest

In another terminal call:

curl -XPOST \
"http://localhost:9000/2015-03-31/functions/function/invocations" \
-d 'Hello from Container Lambda!'

Deployment

cd src

# Build the image
docker build -t lambda-container-demo .

# Create repository
aws ecr create-repository --repository-name lambda-container-demo --image-scanning-configuration scanOnPush=true

# Tag it
docker tag lambda-container-demo:latest 123412341234.dkr.ecr.eu-west-1.amazonaws.com/lambda-container-demo:latest

# Login
aws --region eu-west-1 ecr get-login-password | docker login --username AWS --password-stdin 123412341234.dkr.ecr.eu-west-1.amazonaws.com

# Push the image
docker push 123412341234.dkr.ecr.eu-west-1.amazonaws.com/lambda-container-demo:latest

Then either manually create the Lambda function or use the fresh from the oven CDK deployment.

lambda-container-image-with-custom-runtime-example's People

Contributors

aripalo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lambda-container-image-with-custom-runtime-example's Issues

No port exposed in dockerfile

There is no exposed port in the dockfile. Is this a mistake? I can't test the container function locally without an exposed port.

Wrong CMD- should not include file extension '.sh'

Just based on personal testing and from some documentation:
The standard format is file.method, where file is the name of the file without an extension, and method is the name of a method or function that's defined in the file.

I reckon the Dockerfile should read
CMD [ "function.handler" ] and not CMD [ "function.sh.handler" ]

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.